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:
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
#!/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() |