Lock your PC in Python on Ubuntu

I am making an application that locks the PC using pyGtk, but I have a problem, when I click ok, the button function is to get the time from the textbox, hide the window and then sleep for a while, and finally lock the computer using bash command ... but he just doesn't hide.

and here is the complete program

+2


source to share


2 answers


If you are using Gnome on Ubuntu



import os

os.system('gnome-screensaver-command –-lock')

      

+3


source


Is there any reason the main class is a thread? I would make it just a normal class that would be much easier to debug. The reason why it does not work, is that all the things associated with gtk gtk should occur in the stream, so all methods are called widgets as follows: gobject.idle_add(widget.method_name)

. To hide the password window:gobject.idle_add(self.pwdWindow.hide)

You need import gobject

to first (you may need to install it first).



EDIT: I don't think this was your problem, anyway I edited your program a lot, here is the modified code .

+1


source







All Articles