1, Os.path.join (arg1, arg2)
Concatenate the strings of Arg1 and Arg2 and return the concatenated strings, and if arg1, arg2 is a variable, first convert arg1, arg2 to a string, and then connect.
2, self.settings = Gio.Settings.new ("Com.linuxmint.mintmenu")
In the default environment path, the configuration variable self.settings is created according to the XML configuration file that starts with "Com.linuxmint.mintmenu", which is typically located in the/usr/share/glib-2.0/schemas/directory of the XML configuration file. This includes the list of plug-ins and the key values of the plug-in's own property keys, including the width, height, color, icon size, classification, stickiness (sticky), and the default definition of the type of the keyword's properties.
Then, the code can be self.settings flexibly access and set the properties of the plug-in according to the configuration variables, greatly reducing the redundancy and coupling degree of the code.
3, PYGTK in the use of delay, mainly used in a time-consuming function, such as the main interface to set the transparency or initialization of the main interface function, by increasing the delay so that the function can be completely correct execution.
def __init__ (self, Applet, IID):
self.load_timer_id = Gobject.timeout_add (self.runmainwinload)
def runmainwinload (self):
Gobject.source_remove (self.load_timer_id)
4. Try ... except with try ... except Exception, E: Application Scenario Differences
The latter is included in the former, which is mainly used when the specific type of the exception needs to be specified, "E" for the Code specific error, "cause" represents the cause of the exception, "detail" represents the exception of the specific information and so on, such as the following code:
defBind_hot_key (self):Try: ifSelf.hotkeytext! ="": Self.keybinder.grab (self.hotkeytext) self.keybinder.connect ("Activate", Self.onbindingpress) Self.keybinder.start ()#Binding menu to Hotkey Print "Binding to hot Key:"+Self.hotkeytextexceptException, Cause:Print "* * WARNING * *-Menu Hotkey Binding Error" Print "Error report: \ n", str (cause)Passdefdetect_desktop_environment (self): self.de="Mate" Try: De= os.environ["desktop_session"] ifDeinch["Gnome","Gnome-shell","Mate","KDE","Xfce"]: self.de=deElse: ifOs.path.exists ("/usr/bin/caja"): Self.de="Mate" elifOs.path.exists ("/usr/bin/thunar"): Self.de="Xfce" exceptException, Detail:PrintDetail
5, Self.button_box.set_homogeneous (False) What do you mean?
Homogeneous indicates whether the child widget has the same size True---The child member size is the same false-> the child widget size is determined by the subassembly itself setting properties.
Application of exception in common interfaces and exceptions of OS modules in Python