def __init__(self): global USE_THREADS ttk.Frame.__init__(self, name='application', width=300, height=500) self.pack(expand='yes', fill='both') self.master.title('pjsua2 Demo') self.master.geometry('500x500+100+100') # Logger self.logger = log.Logger() # Accounts self.accList = [] # GUI variables self.showLogWindow = tk.IntVar(value=0) self.quitting = False # Construct GUI self._createWidgets() # Log window self.logWindow = log.LogWindow(self) self._onMenuShowHideLogWindow() # Instantiate endpoint self.ep = endpoint.Endpoint() self.ep.libCreate() # Default config self.appConfig = settings.AppConfig() if USE_THREADS: self.appConfig.epConfig.uaConfig.threadCnt = 1 self.appConfig.epConfig.uaConfig.mainThreadOnly = False else: self.appConfig.epConfig.uaConfig.threadCnt = 0 self.appConfig.epConfig.uaConfig.mainThreadOnly = True self.appConfig.epConfig.logConfig.writer = self.logger self.appConfig.epConfig.logConfig.filename = "pygui.log" self.appConfig.epConfig.logConfig.fileFlags = pj.PJ_O_APPEND self.appConfig.epConfig.logConfig.level = 5 self.appConfig.epConfig.logConfig.consoleLevel = 5
def __init__(self, feedback): """Constructor for a GTK+ glChess GUI""" self.feedback = feedback self._watches = {} self.__networkGames = {} self.newGameDialog = None self.loadGameDialog = None self.__aboutDialog = None self.__saveGameDialogs = {} self.__joinGameDialogs = [] # The time stored for animation self.__lastTime = None self.__animationTimer = None self.__renderGL = False self.openGLInfoPrinted = False self.__attentionCounter = 0 self.whiteTimeString = '∞' self.blackTimeString = '∞' # Theo window width and height when unmaximised and not fullscreen self.width = None self.height = None self.isFullscreen = False self.isMaximised = False self.view = None # Set the message panel to the tooltip style # (copied from Gedit) # In Gtk+ 2.11+ (I think) tip_window is now private so skip if it's not there (bug #459740) w = gtk.Window(gtk.WINDOW_POPUP) w.set_name('gtk-tooltip') w.ensure_style() self._tooltipStyle = w.get_style() self._tooltipWidgetsDrawn = {} self._gui = loadUIFile('glchess.ui') self._gui.connect_signals(self) self.mainWindow = self._gui.get_object('glchess_app') # Create the model for the player types self.__playerModel = gtk.ListStore(str, str, str) iter = self.__playerModel.append() # Translators: Player Type Combo: Player is human controlled self.__playerModel.set(iter, 0, '', 1, 'stock_person', 2, _('Human')) self.__logWindow = log.LogWindow(self._gui.get_object('log_notebook')) # Make preferences dialog self.preferences = dialogs.GtkPreferencesDialog(self) # Balance space on each side of the history combo group = gtk.SizeGroup(gtk.SIZE_GROUP_BOTH) group.add_widget(self.__getWidget('left_nav_box')) group.add_widget(self.__getWidget('right_nav_box')) # History combo displays text data combo = self.__getWidget('history_combo') cell = gtk.CellRendererText() combo.pack_start(cell, False) combo.add_attribute(cell, 'text', 2) # Add launchpad integration widget = self._gui.get_object('help2_menu') LaunchpadIntegration.set_sourcepackagename('glchess') LaunchpadIntegration.add_items(widget, 1, True, False) self._updateViewButtons() # Watch for config changes for key in [ 'show_toolbar', 'show_history', 'fullscreen', 'show_3d', 'show_3d_smooth', 'show_comments', 'show_numbering', 'show_move_hints', 'width', 'height', 'move_format', 'promotion_type', 'board_view', 'enable_networking' ]: glchess.config.watch(key, self.__applyConfig)