Python Forum

Full Version: Gi module window freezing problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello. I code the interface with the gi module. But I am having problems.

For example, the window is frozen when for loops occur. the window will freeze and the window will not react when the terminal side processes occur. What is the solution?

Example Code:
#!/usr/bin/env python

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
import os

class Window(Gtk.Window):
	def __init__(self):
		Gtk.Window.__init__(self, title="Window")
		self.connect("delete-event", Gtk.main_quit)
		self.set_position(Gtk.WindowPosition.CENTER)
		self.unmaximize()
		self.set_resizable(False)

		self.box = Gtk.Box()
		self.add(self.box)

		self.button = Gtk.Button(label="Click")
		self.button.connect("clicked", self.click)

		self.progressbar = Gtk.ProgressBar()


		self.box.pack_start(self.button, True, True, 1)
		self.box.pack_start(self.progressbar, True, True, 2)

	def click(self,widget):
		self.progressbar.pulse()
		os.system("sleep 2")
		self.progressbar.pulse()
		os.system("mkdir A; mkdir AA")
		self.progressbar.pulse()
		os.system("rm -rf A; rm -rf AA")
		self.progressbar.pulse()
		os.system("free")
		return False


	def main(self):
		self.show_all()
		Gtk.main()

win = Window()
win.main()