def preferences(self): ''' Shows the extension preferences dialog''' ''' You don't need to override this''' if self.preferences_dialog == None: self.preferences_dialog = Preferences.Preferences( self._on_config, self.NAME, self.config) self.preferences_dialog.show()
def __init__(self): super(MainWindow, self).__init__() self.samplerate = 44100 self.nchannels = 2 self.audioformat = QAudioFormat() self.updateAudioFormat() self.audiodeviceinfo = QAudioDeviceInfo(QAudioDeviceInfo.defaultOutputDevice()) self.ui = UiMainWindow.Ui_MainWindow() self.ui.setupUi(self) self.ui.timeEdit = QLineEdit("22.3", self) self.ui.timeEdit.setEnabled(False) self.ui.toolBar_3.addWidget(self.ui.timeEdit) self.pages = [] self.ui.tabWidget.setTabsClosable(True) self.preferences = Preferences(".toy210") self.preferences.load() # Populate recent projects list if self.preferences.hasRecents(): self.ui.menu_Recent.removeAction(self.ui.actionNone) for filename in self.preferences.recentfiles: self.ui.menu_Recent.addAction(QAction(QIcon(None), filename, self.ui.menu_Recent))
def preferences(self): ''' Shows the extension preferences dialog You don't need to override this''' config_dialog = self.config_dialog_class(self.config) preferences_dialog = Preferences.Preferences(self._on_config, self.NAME, config_dialog) preferences_dialog.show()
def main(): # Load the configuration file preferences = Preferences.Preferences(args=sys.argv) # Create application app = QtGui.QApplication(sys.argv) # Load the Main Widget mainWindow = MainWindow(preferences) # Start the application sys.exit(app.exec_())
def main(): """The main program.""" # Initialize Pygame pygame.init() # First we set some stuff up. prefs = Preferences.Preferences() prefs.loadPreferences() video = Video.Video(prefs) video.prepareVideo() carObject = Car.Car() groundObject = Map.Map() groundObject.loadMapData(test_map.t_d, test_map.t_w, test_map.t_h) groundObject.setupObjects() carObject.setXYPosition(8.0, 9.0) carDir = 0.0 while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() carDir += 1.0 if (carDir >= 360.0): carDir -= 360.0 carObject.setAngle(carDir) video.prepareNewFrame() video.setupCamera() video.setupLights() # Drawing happens here glLoadIdentity() # drawReference(0.0, 0.0, 0.0, 1.0) groundObject.draw() carObject.draw() video.finishNewFrame() pygame.time.wait(33)
def main(): """The main program.""" # Initialize Pygame pygame.init() # First we set some stuff up. prefs = Preferences.Preferences() prefs.loadPreferences() video = Video.Video(prefs) video.prepareVideo() carObject = Car.Car() groundObject = Ground.Ground() carDir = 0.0 while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() carDir += 1.0 if (carDir >= 360.0): carDir -= 360.0 carObject.setAngle(carDir) video.prepareNewFrame() video.setupCamera() video.setupLights() # Drawing happens here glLoadIdentity() drawReference(0.0, 0.0, 0.0, 1.0) video.drawSimulationObject(groundObject) video.drawSimulationObject(carObject) video.finishNewFrame() pygame.time.wait(33)
def openPreferences(self): self.prefsWindow = tk.Toplevel(self) self.prefsWindow.minsize(500, 90) # create frame to house widgets prefControls_frame = tk.Frame(self.prefsWindow) prefControls_frame.pack(fill=tk.BOTH) # add controls to preferences window self.l_directory = ttk.Label(prefControls_frame, text="Default File(s) Directory:") self.b_dirSelectPrefs = ttk.Button( prefControls_frame, text="Select Directory", command=self.dirSelectPrefs_btnClick) self.l_email = ttk.Label(prefControls_frame, text="Email:") self.e_directory = ttk.Entry(prefControls_frame) self.e_email = tk.Entry(prefControls_frame) self.b_save = ttk.Button(prefControls_frame, text="Save", command=self.updatePreferences) for i in range(5): if (i == 1): prefControls_frame.columnconfigure(i, weight=2) prefControls_frame.rowconfigure(i, weight=1) # prefControls_frame.columnconfigure(1, minsize=100) # add all widgets to grid self.l_directory.grid(row=0, column=0, sticky=tk.W + tk.E) self.l_email.grid(row=1, sticky=tk.W + tk.E) self.e_directory.grid(row=0, column=1, columnspan=1, sticky=tk.W + tk.E) self.e_email.grid(row=1, column=1, columnspan=1, sticky=tk.W + tk.E) self.b_dirSelectPrefs.grid(row=0, column=2, sticky=tk.W + tk.E) self.b_save.grid(row=2, column=2, sticky=tk.W + tk.E) # populate the widgets with our users' preferences userPrefs = Preferences.Preferences() userPrefs.loadPreferences(USER.Username, USER.Password) self.e_directory.insert(0, userPrefs.DefaultDirectory) # "test" self.e_email.insert(0, userPrefs.Email) # "test"
def config(self, session): '''config the plugin''' Preferences.Preferences(self.session)
def __init__(self): ''' creating and packing elements of the GUI ''' tk.Tk.__init__(self) self.title("PYCC") self.openChats = [] self.curChat = '' # initiate preferences self.Preferences = Preferences.Preferences('preferences.cfg') self.username = self.Preferences.prefs['username'] self.textcolor = self.Preferences.prefs['textcolor'] # chat selection self.fChatSelection = tk.Frame(self) self.fChatSelection.grid(row=0, column=0, sticky='w') # set current selected button to None self.activeButton = None # selection between contact list and preferences self.fMenue = tk.Frame(self) self.fMenue.grid(row=0, column=1) self.bContacts = tk.Button(self.fMenue, text='Contacts', command=self.displayContacts, width=6, fg=self.textcolor) self.bContacts.config(relief=tk.SUNKEN) self.bContacts.pack(side='left') self.bPreferences = tk.Button(self.fMenue, text='Prefs', command=self.displayPreferences, width=6, fg=self.textcolor) self.bPreferences.pack(side='left') # chat window self.fChatWindow = tk.Frame(self) self.fChatWindow.grid(row=1, column=0, sticky='nswe') self.sChatWindow = tk.Scrollbar(self.fChatWindow) self.sChatWindow.pack(side='right', fill='y') # read-only; switch back to state = 'normal' to insert text self.tChatWindow = tk.Text(self.fChatWindow, yscrollcommand=self.sChatWindow.set, height=20, state='disabled', fg=self.textcolor) self.tChatWindow.pack(side='left', fill='both', expand=True) self.sChatWindow.config(command=self.tChatWindow.yview) # input window self.fText = tk.Frame(self) self.fText.grid(row=2, column=0, sticky='nswe') self.sText = tk.Scrollbar(self.fText) self.sText.pack(side='right', fill='y') self.tText = tk.Text(self.fText, yscrollcommand=self.sText.set, height=4, state='disabled', fg=self.textcolor) self.tText.pack(side='left', fill='x', expand=True) self.sText.config(command=self.tText.yview) # preferences self.fPreferences = tk.Frame(self) self.sPreferences = tk.Scrollbar(self.fPreferences) self.sPreferences.pack(side='right', fill='y') # username self.fUserName = tk.Frame(self.fPreferences) self.fUserName.pack(padx=10, pady=10, anchor='w') self.lUserName = tk.Label(self.fUserName, text='Username:'******'w', pady=5) self.eUserName = tk.Entry(self.fUserName, width=15, fg=self.textcolor) self.eUserName.insert('end', self.username) self.eUserName.pack(anchor='w') # textcolor self.tc = tk.StringVar() self.fColors = tk.Frame(self.fPreferences) self.fColors.pack(padx=10, anchor='w') self.fColors2 = tk.Frame(self.fPreferences) self.fColors2.pack(padx=10, anchor='w') self.lColors = tk.Label(self.fColors, text='Textcolor:', fg=self.textcolor) self.lColors.pack(anchor='w', pady=5) self.rbBlack = tk.Radiobutton(self.fColors, width=3, variable=self.tc, value='#000000', indicatoron=0, activebackground='#000000', selectcolor='#000000', bg='#444444') self.rbBlack.pack(side='left') self.rbRed = tk.Radiobutton(self.fColors, width=3, variable=self.tc, value='#FF0000', indicatoron=0, activebackground='#FF0000', selectcolor='#FF0000', bg='#DD4444') self.rbRed.pack(side='left') self.rbBlue = tk.Radiobutton(self.fColors, width=3, variable=self.tc, value='#0000FF', indicatoron=0, activebackground='#0000FF', selectcolor='#0000FF', bg='#4444BB') self.rbBlue.pack(side='left') self.rbGreen = tk.Radiobutton(self.fColors, width=3, variable=self.tc, value='#00FF00', indicatoron=0, activebackground='#00FF00', selectcolor='#00FF00', bg='#44DD44') self.rbGreen.pack(side='left') self.rbWhite = tk.Radiobutton(self.fColors2, width=3, variable=self.tc, value='#FFFFFF', indicatoron=0, activebackground='#FFFFFF', selectcolor='#FFFFFF', bg='#EEEEEE') self.rbWhite.pack(side='left') self.rbYellow = tk.Radiobutton(self.fColors2, width=3, variable=self.tc, value='#FFFF00', indicatoron=0, activebackground='#FFFF00', selectcolor='#FFFF00', bg='#DDDD44') self.rbYellow.pack(side='left') self.rbViolet = tk.Radiobutton(self.fColors2, width=3, variable=self.tc, value='#FF00FF', indicatoron=0, activebackground='#FF00FF', selectcolor='#FF00FF', bg='#DD44DD') self.rbViolet.pack(side='left') self.rbTurquoise = tk.Radiobutton(self.fColors2, width=3, variable=self.tc, value='#00FFFF', indicatoron=0, activebackground='#00FFFF', selectcolor='#00FFFF', bg='#44DDDD') self.rbTurquoise.pack(side='left') self.bSave = tk.Button(self.fPreferences, text='Save', width=8, command=self.savePrefs, fg=self.textcolor) self.bSave.pack(padx=10, pady=20, anchor='w') # contact list self.fContacts = tk.Frame(self) self.fContacts.grid(row=1, column=1, rowspan=3, sticky='nswe') self.sContacts = tk.Scrollbar(self.fContacts) self.sContacts.pack(side='right', fill='y') self.lContacts = tk.Listbox(self.fContacts, yscrollcommand=self.sContacts.set, fg=self.textcolor) self.lContacts.pack(side='left', fill='y') self.sContacts.config(command=self.lContacts.yview) # chat buttons self.fChatButtons = tk.Frame(self) self.fChatButtons.grid(row=3, column=0, sticky='w') self.bSend = tk.Button(self.fChatButtons, text='Send', command=self.sendMessage, width=10, state='disabled', fg=self.textcolor) self.bSend.pack(side='left') self.bCloseChat = tk.Button(self.fChatButtons, text='Close Chat', command=self.closeChat, width=10, state='disabled', fg=self.textcolor) self.bCloseChat.pack(side='left') # define expanding rows and columns self.rowconfigure(1, weight=1) self.columnconfigure(0, weight=1) self.columnconfigure(1, minsize=177) # define events self.lContacts.bind('<Double-ButtonPress-1>', self.startChat) self.tText.bind('<KeyRelease-Return>', self.sendMessage) self.tText.bind('<Shift-KeyRelease-Return>', self.newline) self.protocol('WM_DELETE_WINDOW', self.windowClosing) self.frontend = Frontend.Frontend() started = self.frontend.startBackend() if not started: print('Fehler!!!!') else: self.frontend.updateLoopTkinter(self) # add callback to be raised when new message is received self.frontend.addCallback('newMessage', self.gotNewMessage) #load contact list from pycc/.contacts self.frontend.sendRequest('getAccounts', self.gotAccounts)
class MainWindow(QtGui.QMainWindow): # List of plugins plugins = [] # Preferences preferences = Preferences.Preferences() # Constructor def __init__(self, preferences=None): # Create parent super(MainWindow, self).__init__() # Set preferences if not preferences == None: self.preferences = preferences # Create the configuration pane self.configurationPane = ConfigurationPane() # Load Plugins self.loadPlugins() # Initialize the GUI self.initUI() # Show the GUI self.show() # Initialize the User Interface def initUI(self): # Set the window title self.setWindowTitle('UberTool') # Create the scroll area self.mainScrollArea = QtGui.QScrollArea(self) # Create the main widget self.mainWidget = QtGui.QWidget(self.mainScrollArea) # Create the main layout self.mainLayout = QtGui.QGridLayout() self.mainLayout.setSpacing(0) self.mainLayout.setContentsMargins(0, 0, 0, 0) # Initialize the toolbar self.initToolbar() # Set the main widget self.mainWidget.setLayout(self.mainLayout) # Set the scroll area self.mainScrollArea.setWidget(self.mainWidget) # Set the central widget self.setCentralWidget(self.mainScrollArea) # Initialize the toolbar def initToolbar(self): crow = 0 ccol = 0 # Add each button to the toolbar for x in xrange(0, len(self.pluginButtons)): self.mainLayout.addWidget(self.pluginButtons[x], crow, ccol) ccol += 1 if ccol >= int(self.preferences.get('core.ButtonsPerRow')): ccol = 0 crow += 1 if not ccol == 0: ccol = 0 crow += 1 # Create the config button self.configButton = QtGui.QToolButton(self.mainWidget) self.configButton.setText('Configure') self.configButton.setFixedWidth( int(self.preferences.get('core.MainWindowButtonWidth'))) self.configButton.setFixedHeight( int(self.preferences.get('core.MainWindowButtonHeight'))) self.configButton.setIcon( QtGui.QIcon(self.preferences.get('core.IconHome') + '/gear.png')) self.configButton.setIconSize( QSize( int(self.preferences.get('core.MainWindowButtonIconWidth')), int(self.preferences.get('core.MainWindowButtonIconHeight')))) self.configButton.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) self.configButton.clicked.connect(self.openConfigurePane) self.mainLayout.addWidget(self.configButton, crow, ccol) # Create the quit button ccol += 1 self.quitButton = QtGui.QToolButton(self.mainWidget) self.quitButton.setText('Quit') self.quitButton.setFixedWidth( int(self.preferences.get('core.MainWindowButtonWidth'))) self.quitButton.setFixedHeight( int(self.preferences.get('core.MainWindowButtonHeight'))) self.quitButton.setIcon( QtGui.QIcon(self.preferences.get('core.IconHome') + '/close.png')) self.quitButton.setIconSize( QSize( int(self.preferences.get('core.MainWindowButtonIconWidth')), int(self.preferences.get('core.MainWindowButtonIconHeight')))) self.quitButton.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) self.quitButton.clicked.connect(self.close) self.mainLayout.addWidget(self.quitButton, crow, ccol) # Load each plugin def loadPlugins(self): # open the add-on loader addOnLoader = AddOnLoader.AddOnLoader( self.preferences.get('AddOns.ModuleList')) # Get a list of plugins self.plugins = addOnLoader.plugins self.pluginButtons = [] # Add each plugin to the plugin-list for x in xrange(0, len(self.plugins)): # Create the button pluginButton = QtGui.QToolButton() pluginButton.setText(self.plugins[x].getButtonText()) pluginButton.setIcon( QtGui.QIcon( self.preferences.get('core.IconHome') + '/' + self.plugins[x].getButtonIconPath())) pluginButton.setFixedWidth( int(self.preferences.get('core.MainWindowButtonWidth'))) pluginButton.setFixedHeight( int(self.preferences.get('core.MainWindowButtonHeight'))) pluginButton.setIconSize(self.plugins[x].getButtonIconSize()) pluginButton.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) pluginButton.clicked.connect(self.plugins[x].openDialog) self.pluginButtons.append(pluginButton) # Open the configuration pane def openConfigurePane(self): # Open the configuration widget self.configurationPane.show()
def main(): """The main program.""" # Initialize Pygame print "Starting Pygame..." pygame.init() # First we set some stuff up. print "Initializing stuff..." prefs = Preferences.Preferences() prefs.loadPreferences() video = Video.Video(prefs) video.prepareVideo() carObject = Car.Car() groundObject = Map.Map() groundObject.loadMapData(test_map.t_d, test_map.t_w, test_map.t_h) groundObject.setupObjects() carObject.setXYPosition(8.0, 9.0) carDir = 0.0 print "Unpickleing dictionaries..." nodeFile = open("Objects/Map/node_list.dat", "r") distFile = open("Objects/Map/node_distances.dat", "r") nodeDict = pickle.load(nodeFile) distDict = pickle.load(distFile) nodeFile.close() distFile.close() # Now we do things print "Preparing lists for drawing paths..." (points, lines) = VideoRoutines.drawPathsPrep(nodeDict, distDict) print "Starting main loop..." while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() carDir += 1.0 if (carDir >= 360.0): carDir -= 360.0 carObject.setAngle(carDir) video.prepareNewFrame() video.setupCamera() video.setupLights() # Drawing happens here glLoadIdentity() groundObject.draw() carObject.draw() glLoadIdentity() VideoRoutines.drawPaths(points, lines, 20.0, 1.0, 3.0) video.finishNewFrame() pygame.time.wait(33)
def main(): """The main program.""" print "" # Initialize Pygame print "Starting Pygame..." pygame.init() # First we set some stuff up. print "Initializing stuff..." prefs = Preferences.Preferences() prefs.loadPreferences() video = Video.Video(prefs) video.prepareVideo() simulationObject = Simulation.Simulation() carObject = Car.Car() groundObject = Map.Map() print "Unpickleing dictionaries..." nodeFile = open("Objects/Map/node_list.dat", "r") distFile = open("Objects/Map/node_distances.dat", "r") nodeDict = pickle.load(nodeFile) distDict = pickle.load(distFile) nodeFile.close() distFile.close() print "initializing more stuff..." groundObject.loadMapData(test_map.t_d, test_map.t_w, test_map.t_h, nodeDict, distDict) groundObject.setupObjects() simulationObject.setMap(groundObject) simulationObject.addObject(carObject) print "Preparing stuff for the car..." carObject.setXYPosition(2.25, 0.25) carObject.setCurrentNode("0200TL") carObject.setVelocity(2.0) carObject.getNextTarget() # Now we do things print "Preparing lists for drawing paths..." (points, lines) = VideoRoutines.drawPathsPrep(nodeDict, distDict) print "Starting main loop..." while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() simulationObject.update(33.0 / 1000.0) video.prepareNewFrame() video.setupCamera() video.setupLights() # Drawing happens here glLoadIdentity() # groundObject.draw() # carObject.draw() simulationObject.draw() glLoadIdentity() # VideoRoutines.drawPaths(points, lines, 20.0, 1.0, 3.0) VideoRoutines.drawSpecialPath(carObject.getPath(), nodeDict, 20.0, 1.0, 3.0) video.finishNewFrame() pygame.time.wait(33) print "Exiting..." print ""
def dirSelect_btnClick(self): prefs = Preferences.Preferences() prefs.loadPreferences(USER.Username, USER.Password) dirPath = filedialog.askdirectory(initialdir=prefs.DefaultDirectory) self.e_directory.insert(0, dirPath)