def confirmedClear(self): if self.clearTask == True: if util.isMouseover(self.myMouse.get_pos(), self.UnfixedWidget[-1].clear): print "confirm clear" # Integration of Clear Task self.TaskAllocator.clearSched() self.UnfixedWidget = [] self.clearTask = False self.clearButton = Wid.Button2("UI/res/icons/clearButton.png", (625, 110), (50, 50)) msg = "" while (len(self.TaskAllocator.messages) != 0): msg += (self.TaskAllocator.messages.popleft() + "\n") #myAddTaskUI=Wid.AddTaskUI((WIN_SIZE_X/2-225,WIN_SIZE_Y/2-175),(450,350),(182,161,158)) msgUI = Wid.AlertMessagesUI( msg, (WIN_SIZE_X / 2 - 225, WIN_SIZE_Y / 2 - 175), (182, 161, 158), (450, 350)) self.UnfixedWidget = [] self.clearTask = False self.addTask = False self.editTask = False self.UnfixedWidget.append(msgUI)
def __init__(self, parent, screen): self.screen = screen self.parent = parent tk.Frame.__init__(self, parent) tk.Label(self, text=self.screen.name).grid(row=0, column=0, columnspan=2, pady=5) # Changing Frequency Settings cw.BarFreqSettings(self, self.screen).grid(row=1, column=0, sticky=W, pady=5) # Dimension Settings cw.DimensionChangeSettings(self, self.screen, self.screen.changePixel, title="Pixel Size", placeholder=screen.pixel).grid(row=2, column=0, columnspan=2, sticky=W, pady=5) # Connection Settings tcpSet = cw.TCPSettings(self, self.screen) self.write_console = tcpSet.write_console tcpSet.grid(row=3, column=0, columnspan=2, sticky="nsew", pady=5)
def __init__(self, top_lvl, db, master_topic): ''' Initialize a gui for the insertion of students infomation' INPUT: - top_lvl the top_lvl window -db - the databse ''' #create a root container self.root = tk.Toplevel(top_lvl) self.root.title("Edit Topics") self.top_lvl = top_lvl self.master_tp = master_topic #Labels: to the left of the window TopicLNew = wd.LabelWidget(self.root, 0, 0, "New Topic") TopicLNew.config(width=12) TopicLRemove = wd.LabelWidget(self.root, 0, 1, "Remove Topic") TopicLRemove.config(width=12) #Entries: to the right of the window TopicE = wd.EntryWidget(self.root, 1, 0, "") TopicE.config(width=50) OPTIONS = [i[0] for i in db.getTopics()] TopicR = wd.OptionsWidget(self.root, OPTIONS, 1, 1) TopicR.config(width=50) # firstE = wd.EntryWidget(self.root, 1, 1, "") #Log display to the gui log = wd.LabelWidget(self.root, 0, 7, "Status", 30) #having the log display to span 2 columns log.grid(columnspan=2) # def refresh(): # OPTIONS = [i[0] for i in db.getTopics()] # TopicR = wd.OptionsWidget(self.root, OPTIONS ,1, 1) # TopicR.config(width = 50) def ins(): 'method to call for the Submit button' try: #checking if the user had inserted any special note for each students #interaction witht the Database object OPTIONS = [i[0] for i in db.getTopics()] newval = TopicE.getVal() if newval == "": log.set("New Topic is empty") elif newval in OPTIONS: log.set("Topic duplicated") else: db.insTopic(newval) OPTIONS = [i[0] for i in db.getTopics()] TopicR.update_option_menu(OPTIONS) self.master_tp.update_option_menu(OPTIONS) #report that the insertion is success log.set("Success") except Exception, value: #If insertion fail, report to the Log display log.set(value)
def update_mount(self, button, data=None): if not GLIUtility.is_ip(self.mount_info_host.get_text( )) and not GLIUtility.is_hostname(self.mount_info_host.get_text()): msgdialog = Widgets.Widgets().error_Box( "Invalid Host or IP", "You must specify a valid hostname or IP address") result = msgdialog.run() if result == gtk.RESPONSE_ACCEPT: msgdialog.destroy() return if self.mount_info_export.get_child().get_text() == "": msgdialog = Widgets.Widgets().error_Box( "Invalid Entry", "You must enter a value for the export field") result = msgdialog.run() if result == gtk.RESPONSE_ACCEPT: msgdialog.destroy() return if self.mount_info_mountpoint.get_text() == "": msgdialog = Widgets.Widgets().error_Box( "Invalid Entry", "You must enter a mountpoint") result = msgdialog.run() if result == gtk.RESPONSE_ACCEPT: msgdialog.destroy() return if self.active_entry == -1: self.netmounts.append({ 'host': self.mount_info_host.get_text(), 'export': self.mount_info_export.get_child().get_text(), 'type': self.mount_types[self.mount_info_type.get_active()], 'mountpoint': self.mount_info_mountpoint.get_text(), 'mountopts': self.mount_info_mountopts.get_text() }) self.active_entry = -1 self.mount_button_update.set_sensitive(False) self.mount_button_delete.set_sensitive(False) self.mount_button_populate.set_sensitive(False) else: self.netmounts[ self.active_entry]['host'] = self.mount_info_host.get_text() self.netmounts[self.active_entry][ 'export'] = self.mount_info_export.get_child().get_text() self.netmounts[ self.active_entry]['type'] = self.mount_info_type.get_text() self.netmounts[self.active_entry][ 'mountpoint'] = self.mount_info_mountpoint.get_text() self.netmounts[self.active_entry][ 'mountopts'] = self.mount_info_mountopts.get_text() self.refresh_list_at_top() self.disable_all_fields()
def index(self, case_id): store = self.case.get_store(case_id) html = u""" <h3>Dashboard</h3><hr /> """ for wdef in self.widgets: widget = Widgets.get_widget(wdef.widget_id) if widget == None: continue widget.set_title(wdef.title) widget.set_size(wdef.size) res = wdef.data_func(widget, store) if res: html += Widgets.render_widget_object(widget) return html
def index(self, case_id): store = self.case.get_store(case_id) html = u""" <h3>Dashboard</h3><hr /> """ for wdef in self.widgets: widget = Widgets.get_widget(wdef.widget_id) if widget == None: continue widget.set_title( wdef.title ) widget.set_size( wdef.size ) res = wdef.data_func(widget,store) if res: html += Widgets.render_widget_object(widget) return html
def on_actionView_CouchDB_Trace_triggered(self): couchDbDialogue = OpenCouchDatabase(self.workspace) self.workspace.addWindow(couchDbDialogue) couchDbDialogue.showMaximized() if couchDbDialogue.exec_() == QtGui.QDialog.Accepted: couchId = couchDbDialogue.getDatabase() else: return db = desktopcouch.records.server.CouchDatabase(str(couchId), create=False) self.viewCouchDBCanvas = tracing.frameplotter.FramePlotter(db, self.workspace) self.workspace.addWindow(self.viewCouchDBCanvas) self.viewCouchDBCanvas.showMaximized() self.model = tracing.model.TraceEntryTableModel(self) self.viewCouchDBTraceWidget = Widgets.ViewCouchDBTrace(self) self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self.viewCouchDBTraceWidget) self.viewCouchDBTraceWidget.internalWidget.tableView.setModel(self.model) self.viewCouchDBTraceWidget.internalWidget.tableView.resizeColumnsToContents() self.viewCouchDBNavigation = Widgets.TraceNavigation(self) self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.viewCouchDBNavigation) for sender in self.viewCouchDBCanvas.senders: self.viewCouchDBNavigation.internalWidget.senders.addItem(sender) for receiver in self.viewCouchDBCanvas.receivers: self.viewCouchDBNavigation.internalWidget.receivers.addItem(receiver) self.viewCouchDBCanvas.setSelectors(self.viewCouchDBNavigation.internalWidget.senders, self.viewCouchDBNavigation.internalWidget.receivers, self.viewCouchDBNavigation.internalWidget.applyFilterCheckbox, self.viewCouchDBNavigation.internalWidget.customFilter) self.viewCouchDBCanvas.plotRadioFrame() self.connect(self.viewCouchDBNavigation, QtCore.SIGNAL("radioFrameChanged(int, int)"), self.viewCouchDBCanvas.on_radioFrameChanged) self.connect(self.viewCouchDBCanvas, QtCore.SIGNAL("itemPicked"), self.model.addItem) self.connect(self.viewCouchDBTraceWidget.internalWidget.clearButton, QtCore.SIGNAL("clicked()"), self.model.clear) self.actionOpenCampaignDatabase.setEnabled(False) self.actionView_CouchDB_Trace.setEnabled(False) self.actionOpenDSV.setEnabled(False) self.actionOpenDirectory.setEnabled(False) self.actionView_Scenario.setEnabled(False) self.actionCloseDataSource.setEnabled(True)
def Update_Board( self): # Update the game board display, kill old, create new for widget in self.Board_Display.winfo_children(): widget.destroy() for y in range(self.controller.Handler.GameParams["y_size"]): row = [] for x in range(self.controller.Handler.GameParams["x_size"]): self.Board_Area.grid_columnconfigure(x, weight=1) self.Board_Area.grid_rowconfigure(y, weight=1) col = None place_col = self.controller.Handler.Game.Board[y][x] if place_col == "B": col = "black" elif place_col == "W": col = "white" disc = wg.Disc(self.Board_Display, self.controller, col=col, diameter=50) disc.grid(row=y, column=x, sticky="nsew") row.append(disc) self.Board.append(row)
def Setup_Board(self): for widget in self.Board_Area.winfo_children(): widget.destroy() self.Board = [] for y in range(self.controller.Handler.GameParams["y_size"]): row = [] for x in range(self.controller.Handler.GameParams["x_size"]): # Diameter with respond to the length of the shortest side of the board height = self.Board_Area.winfo_height() width = self.Board_Area.winfo_width() if height > width: diameter = width / self.controller.Handler.GameParams[ "x_size"] else: diameter = height / self.controller.Handler.GameParams[ "y_size"] self.Board_Area.grid_columnconfigure(x, weight=1) self.Board_Area.grid_rowconfigure(y, weight=1) disc = wg.Disc(self.Board_Area, self.controller, diameter=diameter, mode="setup") disc.grid(row=y, column=x, sticky="nsew") row.append(disc) self.Board.append(row)
def __response_handler(self, curpos, mlist): # answers for responses try: ww = Widgets.Widgets() while len(mlist) < 4: mlist.append([0, "Error"]) uinput1 = ww.showDialog1(curpos, Matcher.__dictdb[mlist[0][1]]) if uinput1 == "y": data = [curpos, Matcher.__dictdb[mlist[0][1]]] Matcher.__csv_writer(self.__rfilepath, data) Matcher.__dictdb[curpos] = data[1] elif uinput1 == "garb": Matcher.__csv_writer(self.__rfilepath2, [curpos]) Matcher.__dictallbd[curpos] = curpos else: dictemp = { "1": Matcher.__dictdb[mlist[1][1]], "2": Matcher.__dictdb[mlist[2][1]], "3": Matcher.__dictdb[mlist[3][1]] } uinput2 = ww.showDialog2(Matcher.__dictdb[mlist[1][1]], Matcher.__dictdb[mlist[2][1]], Matcher.__dictdb[mlist[3][1]]) if uinput2 == "1" or uinput2 == "2" or uinput2 == "3": data = [curpos, dictemp.get(uinput2)] Matcher.__csv_writer(self.__rfilepath, data) Matcher.__dictdb[curpos] = data[1] else: uinput3 = ww.showDialog() data = [curpos, uinput3] Matcher.__csv_writer(self.__rfilepath, data) Matcher.__dictdb[curpos] = data[1] except IndexError: print("list out of bonds")
def __init__(self): QtGui.QMainWindow.__init__(self,None,QtCore.Qt.WindowStaysOnTopHint|QtCore.Qt.FramelessWindowHint) self.setAttribute(QtCore.Qt.WA_TranslucentBackground,True) self.setAttribute(QtCore.Qt.WA_X11NetWmWindowTypeDock,True) self.setWindowTitle("ducklauncher!!")#recognisable by wnck self.activateWindow() #screen size d = QtGui.QDesktopWidget() self.top_pos=0 self.s_width = d.availableGeometry().width() self.s_height =d.availableGeometry().height() self.top_pos= d.availableGeometry().y() #Config values conf=Config.get() self.conf=conf self.HALF_OPEN_POS=int(conf['size']) self.ICO_TOP=self.HALF_OPEN_POS-5 self.OPEN_STATE_TOP=self.ICO_TOP*4+5 self.SIZE = 14 #Geometry self.setGeometry(0,self.top_pos,self.HALF_OPEN_POS+9,self.s_height) #Values self.ICON_SIZE=int(conf['icon-size']) self.apps_per_row = math.trunc(((self.s_width/3)-50)/ int(self.conf["icon-size"])) self.apps_per_col = math.trunc(((self.s_height)-90)/ int(self.conf["icon-size"])) self.apps_per_page=self.apps_per_col*self.apps_per_row self.app_page_state=0 self.appRect=None self.drawAppRect=False self.pos_x=self.HALF_OPEN_POS-2 self.move=False self.current_state="half_open" self.activity="apps" self.dock_apps = Apps.find_info(self.conf['dock-apps']) self.current_text='' self.allApps=Apps.info(self.current_text) self.plugin=False self.pl_rect_pos=0 self.pl_logo=None self.fg_color=(int(self.conf['r']),int(self.conf['g']),int(self.conf['b'])) self.font_color=(int(self.conf['font-r']),int(self.conf['font-g']),int(self.conf['font-b'])) ##Windows #Enables the server which gets open windows self.op_thread=Window.openWindowsThread() self.op_thread.start() self.connect(self.op_thread,QtCore.SIGNAL("new-window"),self.addOpenWindow) self.connect(self.op_thread,QtCore.SIGNAL("remove-window"),self.updateOpenWindows) self.open_windows=Window.get_open_windows() self.ow_in_dock=[] #Dock Apps Options Window self.dock_options_win=DockAppsOptions.Window(parent=self) #Webview (for plugins, files, and settings view) self.webview=Widgets.pluginView(self) self.webview.setGeometry(2,60,self.s_width/3-20,self.s_height-60) #System window self.sys_win=System.Window() #Fake window, required to capture keyboard events self.fakewin = Fakewin(10,10, self) self.fakewin.show() XlibStuff.fix_window(self.winId(),self.HALF_OPEN_POS+3,0,0,0)
def drawUI(self, positionreferencecounter): self.AppDisplay.fill(BACGROUND_COLOR) #pygame.draw.rect(self.AppDisplay,BACGROUND_COLOR,(650,0,WIN_SIZE_X,WIN_SIZE_Y)) self.taskPane.draw(self.AppDisplay) self.addButton.draw(self.AppDisplay) self.clearButton.draw(self.AppDisplay) #draw task self.AllocationSpaceUI = [] #positionreferencecounter=0 X = self.TaskAllocator.CS.sched while X != None: TBUI = Wid.TimeBlockUI( (205, 105 + (49 * positionreferencecounter)), (107, 186, 167), (390, 50), X) if TBUI.status == None: TBUI.color = (220, 199, 170) elif TBUI.status.tType == 1: TBUI.color = (251, 161, 0) self.AllocationSpaceUI.append(TBUI) positionreferencecounter += 1 X = X.next for i in self.AllocationSpaceUI: i.draw(self.AppDisplay) for i in self.UnfixedWidget: i.draw(self.AppDisplay) pygame.draw.rect(self.AppDisplay, BACGROUND_COLOR, ((0, 550), (800, 50))) pygame.draw.rect(self.AppDisplay, BACGROUND_COLOR, ((0, 0), (800, 50))) self.taskPaneHeader.draw(self.AppDisplay) self.taskPaneHeader.addText("Task", (250, 15), self.AppDisplay)
def __init__(self, top_lvl, db): ''' Initialize a gui for the insertion of students infomation' INPUT: - top_lvl the top_lvl window -db - the databse ''' #create a root container self.root = tk.Toplevel(top_lvl) self.root.title("Edit Topics") self.top_lvl = top_lvl #Log display to the gui log = wd.LabelWidget(self.root, 0, 7, "Status", 30) #having the log display to span 2 columns log.grid(columnspan=4) def exportDB(): 'method to call for the Submit button' try: csv_directory = tkFileDialog.asksaveasfilename() db.export_csv(csv_directory) log.set("Exported:" + csv_directory) except Exception, value: #If insertion fail, report to the Log display log.set(value)
def __GUI_init__( self ): # This will initiate the game board once all the datya is provided. for y in range(self.controller.Handler.GameParams["y_size"]): row = [] for x in range(self.controller.Handler.GameParams["x_size"]): # Diameter with respond to the length of the shortest side of the board height = self.Board_Area.winfo_height() width = self.Board_Area.winfo_width() if height > width: diameter = width / self.controller.Handler.GameParams[ "x_size"] else: diameter = height / self.controller.Handler.GameParams[ "y_size"] self.Board_Area.grid_columnconfigure(x, weight=1) self.Board_Area.grid_rowconfigure(y, weight=1) disc = wg.Disc( self.Board_Area, self.controller, diameter=diameter, command=lambda x=x, y=y: self.Disc_Function(x, y)) disc.grid(row=y, column=x, sticky="nsew") row.append(disc) self.Board.append(row) self.Update_Board()
def __init__(self, container=None, icon_file=None, stock_icon=None, title=None, trayify=False, gravity='center', x_size=None, y_size=None, encoding='latin-1'): Base.__init__(self, container, encoding) self.icon_file = icon_file self.stock_icon = stock_icon self.title = title self.focus_offset = False self.encoding = encoding self.gravity = gravity self.x_size = x_size self.y_size = y_size self.trayify = trayify self.TrayIcon = Widgets.TrayIcon() if self.container <> None: self.initialize()
def removeTagsFromSelection (self): if not hasattr(self,'_remove_tag_dialog'): self._remove_tag_dialog = Widgets.SelectTagsDialog(self,modal=True,caption="Remove Tags",ok_button="Remove"); # get set of all tags in selected sources tags = set(); for src in self.model.sources: if src.selected: tags.update(src.getTagNames()); if not tags: return; tags = list(tags); tags.sort(); # show dialog self._remove_tag_dialog.setTags(tags); if self._remove_tag_dialog.exec_() != QDialog.Accepted: return; tags = self._remove_tag_dialog.getSelectedTags(); if not tags: return; # ask for confirmation plural = (len(tags)>1 and "s") or ""; if QMessageBox.question(self,"Removing tags","<P>Really remove the tag%s '%s' from selected sources?</P>"%(plural,"', '".join(tags)), QMessageBox.Yes|QMessageBox.No,QMessageBox.Yes) != QMessageBox.Yes: return; # remove the tags for src in self.model.sources: if src.selected: for tag in tags: src.removeAttribute(tag); # update model self.model.scanTags(); self.model.initGroupings(); # emit signal what = SkyModel.UpdateSourceContent+SkyModel.UpdateTags+SkyModel.UpdateSelectionOnly; self.model.emitUpdate(what,origin=self);
def ClickAddButton(self): if self.addTask == False and self.clearTask == False: if util.isMouseover(self.myMouse.get_pos(), self.addButton): self.addButton = Wid.Button2( "UI\\res\icons\\addButtonClicked.png", (625, 50), (50, 50)) myAddTaskUI = Wid.AddTaskUI( (WIN_SIZE_X / 2 - 225, WIN_SIZE_Y / 2 - 175), (450, 350), (108, 206, 203)) self.UnfixedWidget.append(myAddTaskUI) self.addTask = True #reinitialize all addTask states to False elif self.addTask == True: if util.isMouseover(self.myMouse.get_pos(), self.addButton): self.addButton = Wid.Button2("UI\\res\icons\\addButton.png", (625, 50), (50, 50)) self.UnfixedWidget.remove(self.UnfixedWidget[-1]) self.addTask = False
def cancelClear(self): if self.clearTask == True: if util.isMouseover(self.myMouse.get_pos(), self.UnfixedWidget[-1].cancel): print "cancel" self.UnfixedWidget = [] self.clearTask = False self.clearButton = Wid.Button2("UI/res/icons/clearButton.png", (625, 110), (50, 50))
def ClickClearButton(self): if self.clearTask == False and self.addTask == False: if util.isMouseover(self.myMouse.get_pos(), self.clearButton): self.clearButton = Wid.Button2( "UI\\res\icons\\clearButtonClicked.png", (625, 110), (50, 50)) self.clearTask = True myMessageUI = Wid.MessageDialog( (WIN_SIZE_X / 2 - 150, WIN_SIZE_Y / 2 - 175), (108, 206, 203), (300, 150), "Would you like to Clear all Task?") self.UnfixedWidget.append(myMessageUI) elif self.clearTask == True: if util.isMouseover(self.myMouse.get_pos(), self.clearButton): self.clearButton = Wid.Button2( "UI\\res\icons\\clearButton.png", (625, 110), (50, 50)) self.UnfixedWidget.remove(self.UnfixedWidget[-1]) self.clearTask = False
def cancelAdd(self): #cancel if self.addTask == True: if util.isMouseover(self.myMouse.get_pos(), self.UnfixedWidget[-1].cancel): print "cancel" self.UnfixedWidget = [] self.addTask = False getTask = False self.addButton = Wid.Button2("UI\\res\icons\\addButton.png", (625, 50), (50, 50))
def __init__(self, parentUI, controller, mail='', localavatar=False): gtk.HBox.__init__(self) self.parentUI = parentUI self.controller = controller self.config = controller.config self.mail = mail self.hidebutton = gtk.Button() self.hidebutton.connect('clicked', self.hideShowButton) self.hidebutton.set_relief(gtk.RELIEF_NONE) self.hidebuttonArrow = Widgets.TinyArrow(gtk.ARROW_RIGHT) self.hidebutton.add(self.hidebuttonArrow) self.image = Widgets.avatarHolder(cellKeyPosition=gtk.ANCHOR_SOUTH) self.imageEventBox = gtk.EventBox() self.imageEventBox.set_events(gtk.gdk.BUTTON_PRESS_MASK) self.imageEventBox.set_visible_window(False) self.imageEventBox.add(self.image) if mail: contact = self.controller.getContact(mail) if contact: self.image.set_from_pixbuf( self.controller.theme.getUserDisplayPicture(contact)) self.controller.msn.connect('display-picture-changed', self.on_display_picture_changed) self.key = 'showAvatarOther' else: if self.controller.avatar: self.image.set_from_pixbuf(self.controller.avatar.getImage()) else: self.image.set_from_pixbuf( self.controller.theme.getImage('icon96')) self.controller.connect('avatar-changed', self.on_display_picture_changed) self.imageEventBox.connect('button-press-event', lambda w, e: self.controller.set_picture_dialog()) self.key = 'showAvatarMine' self.filler = gtk.VBox() self.vboxButtonFrame = gtk.VBox() self.vboxButtonFrame.pack_start(self.hidebutton, False, False) self.vboxButtonFrame.pack_start(self.filler, True, True) self.filler2 = gtk.VBox() self.vboxAvatarFrame = gtk.VBox() self.vboxAvatarFrame.pack_start(self.imageEventBox, False, False) self.vboxAvatarFrame.pack_start(self.filler2, True, True) self.container = gtk.VBox() if localavatar: self.container.pack_start(self.vboxButtonFrame, False, False) self.container.pack_start(self.vboxAvatarFrame, False, False) else: self.container.pack_start(self.vboxAvatarFrame, False, False) self.container.pack_start(self.vboxButtonFrame, False, False) self.pack_start(self.container, False, False) self.update()
def draw(self): self.logger.info('.draw()') master = self.root menu = Widgets.MainMenu(master, self.dataStream) toolbar = Widgets.Toolbar(master, self.dataStream) board_left = Frame(master) board_right = Frame(master) sidebar = Widgets.ArgsCheckBar(board_left, self.dataStream) filelist = Widgets.FileList(board_left, self.dataStream) GsMaker = Makegs() menuTexts = [ ('菜单', [ ('路径设置', menu.PathConfig), ('退出', self.quit), ]), ] menu.draw(menuTexts) thePoster = Widgets.Poster(board_right, self.dataStream) toolbar.draw(funcs={ "argsCheckBar": [board_left, board_right], "sidebar": sidebar }) toolbar.pack(fill=X) sidebar.draw(self.hisTexts, Poster=thePoster, Makegs=GsMaker) sidebar.pack(side=TOP, fill=BOTH) board_left.pack(side=LEFT, fill=BOTH) board_right.pack(side=LEFT, fill=BOTH, expand=TRUE) filelist.draw(thePoster=thePoster) filelist.pack(fill=BOTH, expand=True) thePoster.pack(side=LEFT, expand=True, fill=BOTH)
def ClickAddButton(self): #print self.addTask,self.clearTask,self.deleteTask if self.addTask == False and self.clearTask == False and self.deleteTask == False: if util.isMouseover(self.myMouse.get_pos(), self.addButton): self.addButton = Wid.Button2( "UI/res/icons/addButtonClicked.png", (625, 50), (50, 50)) self.UnfixedWidget = [] myAddTaskUI = Wid.AddTaskUI( (WIN_SIZE_X / 2 - 225, WIN_SIZE_Y / 2 - 175), (450, 350), (182, 161, 158)) self.UnfixedWidget.append(myAddTaskUI) self.addTask = True self.clearTask = False self.deleteTask = False self.editTask = False #reinitialize all addTask states to False elif self.addTask == True: if util.isMouseover(self.myMouse.get_pos(), self.addButton): self.addButton = Wid.Button2("UI/res/icons/addButton.png", (625, 50), (50, 50)) self.UnfixedWidget.remove(self.UnfixedWidget[-1]) self.addTask = False
def __init__(self, window: Window, *args, **kwargs): # Initiating tkinter application tk.Tk.__init__(self, *args, **kwargs) self.protocol("WM_DELETE_WINDOW", self.quit) self.title(info['programName'] + ' v' + info['version'] + ' - by ' + info['author']) self._running = True # Define LED Screen Layout module self.queue = Queue() self.managerProc = Process(target=ledScreenLayoutManager.run, args=(self.queue, )) # Integrating pygame window self.window = window self.frame = tk.Frame(self, width=self.window.width, height=self.window.height) self.frame.pack(side=LEFT) os.environ['SDL_WINDOWID'] = str(self.frame.winfo_id()) os.environ['SDL_VIDEODRIVER'] = 'windib' # Screen Settings Panel self.settingSelector = cw.SettingsPanel(self) self.settingSelector.pack(fill=X) self.SettingsContainer = cw.FrameWithWin(self, self.window) self.SettingsContainer.pack(fill=BOTH, expand=YES) self.config(menu=VisualiserMenubar( self)) # Needs to be after declaration of self.settingSelector self.settingsPanels = [] # Create all the Frames for the settings panels for n, i in enumerate(self.window.screens): self.settingsPanels.append(i.createSettings( self.SettingsContainer)) self.settingsPanels[-1].grid(row=0, column=0) self.settingSelector.selectSetting()
def get_choice(self): try: txt = Widgets.get_active_text(self.comboboxentry_speed) options = { 'Instant': 5, 'Fast': 50, 'Medium': 150, 'Slow': 500 } choice = options[txt] except Exception,info: print info choice = 150
def confirmAdd(self): #add if self.addTask == True: if util.isMouseover(self.myMouse.get_pos(), self.UnfixedWidget[-1].add): print "confirm add" self.extractData() self.UnfixedWidget = [] self.addTask = False getTask = False self.addButton = Wid.Button2("UI\\res\icons\\addButton.png", (625, 50), (50, 50)) #print data //stime,etime,duration,status,prevb,nextb '''Sharleen dito mo i-integrate yung function mos add'''
def updateCollections(self, *args): # Cook at Dot node, aka at 'clean' point before any new attribute has been set by SuperTool collectionNames = ScriptActions.cookCollections(root=self.root, node=SuperToolUtils.GetRefNode(self.node, Constants.DOT_KEY ) ).keys() ScriptActions.setColourAttributes(collectionNames, SuperToolUtils.GetRefNode(self.node, Constants.ATTRSET_KEY ), root=self.root, ) # Re-cook since previous nodes added attributes self.collections = ScriptActions.cookCollections(root=self.root, node=SuperToolUtils.GetRefNode(self.node, Constants.ATTRSET_KEY ) ) ScriptActions.buildMaterials(self.collections, SuperToolUtils.GetRefNode(self.node, Constants.MAT_KEY ), ) ScriptActions.createAssignOpScripts(self.collections.keys(), SuperToolUtils.GetRefNode(self.node, Constants.OPSCRIPT_ASSIGN_KEY ), root=self.root) ScriptActions.createOverrideOpScripts(self.collections.keys(), SuperToolUtils.GetRefNode(self.node, Constants.OPSCRIPT_OVERRIDE_KEY ), root=self.root) self.collectionsList.clear() self.items = [] # Need to store items so Qt doesn't remove the objects from memory after the clear call idx = 0 for collection, attrs in self.collections.items(): self.items.append(Widgets.ColourCollectionItem(collection, attrs["colour"])) self.collectionsList.addItem(self.items[idx]) idx = idx + 1
def get_choice(self): try: languages = { 'Catalan': 'ca', 'Dutch': 'nl', 'English': 'en', 'French': 'fr', 'Norwegian': 'no', 'Romenian':'ro', 'Spanish':'es', 'Italian':'it' } choice = languages[Widgets.get_active_text(self.comboboxentry_language)] except Exception,info: print info choice = 'en'
def addTagToSelection (self): if not hasattr(self,'_add_tag_dialog'): self._add_tag_dialog = Widgets.AddTagDialog(self,modal=True); self._add_tag_dialog.setTags(self.model.tagnames); self._add_tag_dialog.setValue(True); if self._add_tag_dialog.exec_() != QDialog.Accepted: return; tagname,value = self._add_tag_dialog.getTag(); if tagname is None or value is None: return None; dprint(1,"tagging selected sources with",tagname,value); # tag selected sources for src in self.model.sources: if src.selected: src.setAttribute(tagname,value); # If tag is not new, set a UpdateSelectionOnly flag on the signal dprint(1,"adding tag to model"); self.model.addTag(tagname); dprint(1,"recomputing totals"); self.model.getTagGrouping(tagname).computeTotal(self.model.sources); dprint(1,"emitting update signal"); what = SkyModel.UpdateSourceContent+SkyModel.UpdateTags+SkyModel.UpdateSelectionOnly; self.model.emitUpdate(what,origin=self);
def __init__(self, parent, node): super(ColourCollectionsEditor, self).__init__(parent=parent) node.upgrade() self.node = node self.root = Constants.DEFAULT_LOCATION self.collections = {} self.items = [] layout = QtWidgets.QVBoxLayout(self) # Root parameter self.locationPolicy = UI4.FormMaster.CreateParameterPolicy( None, self.node.getParameter(Constants.LOCATION_PARAM) ) factory = UI4.FormMaster.KatanaFactory.ParameterWidgetFactory self.locationWidget = factory.buildWidget(self, self.locationPolicy) self.locationPolicy.addCallback(self.__onLocationChanged) layout.addWidget(self.locationWidget) # This widget is not displayed, it is used for scenegraph callback purposes self.scenegraphViewRoot = UI4.Widgets.SceneGraphView() self.scenegraphViewRoot.addTopLevelLocation(self.root) self.scenegraphViewRoot.setLocationAddedOrUpdatedCallback(self._onLocationDataUpdated) self.collectionsList = Widgets.ColourCollectionsList(self.root) self.collectionsList.signals.colourChangeSignal.connect(self.onColourChanged) layout.addWidget(self.collectionsList) # Button to refresh (re-cook and update) # Usually not needed, but available if necessary self.refreshButton = UI4.Widgets.ToolbarButton( "Refresh", self, UI4.Util.IconManager.GetPixmap("Icons/reload16.png"), rolloverPixmap=UI4.Util.IconManager.GetPixmap("Icons/reload_hilite16.png"), ) self.refreshButton.clicked.connect(self.updateCollections) layout.addWidget(self.refreshButton)
def populate_exports(self, button, data=None): host = self.mount_info_host.get_text() oldtext = self.mount_info_export.get_child().get_text() if GLIUtility.is_ip(host) or GLIUtility.is_hostname(host): remotemounts = commands.getoutput( "/usr/sbin/showmount -e " + host + " 2>&1 | egrep '^/' | cut -d ' ' -f 1 && echo") mountlist = gtk.ListStore(gobject.TYPE_STRING) self.mount_info_export.set_model(mountlist) while remotemounts.find("\n") != -1: index = remotemounts.find("\n") + 1 remotemount = remotemounts[:index] remotemounts = remotemounts[index:] remotemount = string.strip(remotemount) mountlist.append([remotemount]) self.mount_info_export.get_child().set_text(oldtext) else: msgdialog = Widgets.Widgets().error_Box( "Invalid Host or IP", "You must specify a valid hostname or IP address to scan for exports" ) result = msgdialog.run() if result == gtk.RESPONSE_ACCEPT: msgdialog.destroy()
def buildInterface(self, interface): self.currentInterface = interface lUser = gtk.Label(_('_User:'******'_Password:'******'_Status:')) lUser.set_use_underline(True) lPass.set_use_underline(True) lStatus.set_use_underline(True) #we add the completion to the user entry self.tUser = gtk.combo_box_entry_new_text() self.userListStore = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf) self.userCompletion = gtk.EntryCompletion() #set up the completion on entry child self.tUser.get_children()[0].set_completion(self.userCompletion) self.userCompletion.set_model(self.userListStore) self.userPixbufCell = gtk.CellRendererPixbuf() self.userCompletion.pack_start(self.userPixbufCell) self.userCompletion.add_attribute(self.userPixbufCell, 'pixbuf', 1) # create a gtk.CellRendererText and pack it in the completion. # Also set the 'text' attribute self.userCompletion.set_text_column(0) self.userCompletion.connect('match-selected', self.matchSelected) self.tUser.connect("changed", self.on_comboxEntry_changed) self.tUser.connect("key-release-event", self.on_comboxEntry_keyrelease) self.statusListStore = gtk.ListStore(gtk.gdk.Pixbuf, gobject.TYPE_STRING, gobject.TYPE_STRING) self.tStatus = gtk.ComboBox(self.statusListStore) self.statusPixbufCell = gtk.CellRendererPixbuf() self.statusTextCell = gtk.CellRendererText() self.tStatus.pack_start(self.statusPixbufCell, False) self.tStatus.pack_start(self.statusTextCell, False) self.statusPixbufCell.set_property('xalign', 0.0) self.statusPixbufCell.set_property('xpad', 5) self.statusTextCell.set_property('xalign', 0.0) self.statusTextCell.set_property('xpad', 5) self.tStatus.add_attribute(self.statusTextCell, 'text', 2) self.tStatus.add_attribute(self.statusPixbufCell, 'pixbuf', 0) self.tPass = gtk.Entry(128) self.tPass.set_visibility(False) self.tPass.connect('activate' , self.bLogin_clicked) lUser.set_mnemonic_widget(self.tUser) lPass.set_mnemonic_widget(self.tPass) lStatus.set_mnemonic_widget(self.tStatus) # fill the status combobox self.statusList = [] j = 0 for i in self.controller.status_ordered[ 1 ]: if i != 'offline': self.statusListStore\ .append([ self.controller.theme.statusToPixbuf( emesenelib.common.status_table[i]), i, _(self.controller.status_ordered[2][ j]) ]) self.statusList.append(i) j += 1 self.tStatus.set_active(0) pixbuf = self.controller.theme.getImage('login', False) self.loginImage = Widgets.avatarHolder() self.loginImage.set_from_pixbuf(pixbuf) self.pack_start(self.loginImage , True , False) self.fieldsBox = gtk.VBox(spacing=10) userBox = gtk.VBox(spacing=4) lUser.set_alignment(0.0, 0.5) userBox.pack_start(lUser , False , False) userBox.pack_start(self.tUser , False , False) self.fieldsBox.pack_start(userBox, False, False) passBox = gtk.VBox(spacing=4) lPass.set_alignment(0.0, 0.5) passBox.pack_start(lPass , False , False) passBox.pack_start(self.tPass , False , False) self.fieldsBox.pack_start(passBox, False, False) statusBox = gtk.VBox(spacing=4) lStatus.set_alignment(0.0, 0.5) statusBox.pack_start(lStatus , False , False) statusBox.pack_end(self.tStatus, True, True) self.fieldsBox.pack_start(statusBox, False, False) fieldsAlig = gtk.Alignment(0.5, 0.5, 0.75, 0.0) fieldsAlig.add(self.fieldsBox) self.pack_start(fieldsAlig, True, False) buttonBox = gtk.HButtonBox() if interface == 'login': self.bLogin = gtk.Button(_('_Login'), gtk.STOCK_CONNECT) self.bLogin.connect('clicked' , self.bLogin_clicked) buttonBox.pack_start(self.bLogin, False, False) self.cRemember = gtk.CheckButton(_('_Remember me'), True) self.cRemember.connect('toggled' , self.on_cRemember_toggled) self.forgetMe = gtk.EventBox() self.forgetMe.set_events(gtk.gdk.BUTTON_PRESS_MASK) self.forgetMeLabel = gtk.Label('<span foreground="#0000AA">(' + \ _('Forget me') + ')</span>') self.forgetMeLabel.set_use_markup(True) self.forgetMe.add(self.forgetMeLabel) self.forgetMe.connect('button_press_event', self.onForgetMe) self.cRememberPass = gtk.CheckButton(_('R_emember password'), True) self.cRememberPass.connect('toggled' , self.on_cRememberPass_toggled) # TODO: find a better description and get-text it self.cAutoLogin = gtk.CheckButton(_('Auto-Login'), True) self.cAutoLogin.connect('toggled' , self.on_cAutoLogin_toggled) if self.controller.config.glob['rememberMe']: self.cRemember.set_active(True) if self.controller.config.glob['rememberMyPassword']: self.cRememberPass.set_active(True) self.checkBox = gtk.VBox(spacing=4) rememberBox = gtk.HBox(spacing=4) rememberBox.pack_start(self.cRemember , False , False) rememberBox.pack_start(self.forgetMe , False , False) self.checkBox.pack_start(rememberBox, False, False) self.checkBox.pack_start(self.cRememberPass , False , False) self.checkBox.pack_start(self.cAutoLogin , False , False) checkAlig = gtk.Alignment(0.5, 0.5) checkAlig.add(self.checkBox) self.pack_start(checkAlig , True , False) elif interface == 'reconnect': self.fieldsBox.set_sensitive(False) self.lConnectionError = gtk.Label() self.lConnectionError.set_markup('<b>' + _('Connection error') + '</b>') self.lReconnectCounter = gtk.Label() self.bCancelReconnect = gtk.Button(_('Cancel'), gtk.STOCK_CANCEL) self.bCancelReconnect.connect('clicked', self.onCancelReconnect) self.pack_start(self.lConnectionError, True, False) self.pack_start(self.lReconnectCounter, True, False) buttonBox.pack_start(self.bCancelReconnect, False, False) elif interface == 'loading': self.fieldsBox.set_sensitive(False) pixbuf = self.controller.theme.getImage('loading', True) self.loading = gtk.image_new_from_animation(pixbuf) cancelButton = gtk.Button(_('Cancel'), gtk.STOCK_CANCEL) cancelButton.connect('clicked', self.onCancelLogin) buttonBox.pack_start(cancelButton, False, False) self.pack_start(self.loading, False, False) # XXX: progress stuff maybe? self.pack_start(buttonBox, True, False) self.fillUserList() self.show_all() self.tUser.grab_focus()
def __init__(self): pygame.init() self.AppDisplay = pygame.display.set_mode((WIN_SIZE_X, WIN_SIZE_Y)) self.myMouse = pygame.mouse self.myMouse.set_cursor(*pygame.cursors.arrow) #initialize primary widgets self.taskPaneHeader = Wid.TaskPaneHeader((100, 50), (71, 62, 63), (500, 50), "Time") self.taskPane = Wid.TaskPane((100, 50), (239, 113, 38), (500, 500)) self.addButton = Wid.Button2("UI\\res\icons\\addButton.png", (625, 50), (50, 50)) self.clearButton = Wid.Button2("UI\\res\icons\\clearButton.png", (625, 110), (50, 50)) self.UnfixedWidget = [] #add Allocation instance self.CS = Dat.Schedule() self.AllocationSpaceUI = [] TB = self.CS.sched positionreferencecounter = 0 while TB != None: self.AllocationSpaceUI.append( Wid.TimeBlockUI((205, 105 + (49 * positionreferencecounter)), (255, 222, 0), (390, 50), TB)) positionreferencecounter += 1 TB = TB.next #States AppExit = False self.addTask = False self.getTask = False self.getDuration = False self.blinkSwitch = 0 self.clearTask = False #counter-> this variables is for getting input self.getdurationcounter = 0 self.getmustartcounter = 0 self.getlowerboundcounter = 0 self.getupperboundcounter = 0 self.getprioritycounter = 2 #this variable determines what input is being done self.addState = None clock = pygame.time.Clock() while not AppExit: for event in pygame.event.get(): if event.type == pygame.QUIT: #exit when exit button si clicked AppExit = True elif event.type == pygame.MOUSEMOTION: #change mouse pointer when over a addButton #if util.isMouseover(self.myMouse.get_pos(),self.addButton): # self.myMouse.set_cursor(*pygame.cursors.broken_x) #if not util.isMouseover(self.myMouse.get_pos(),self.addButton): # self.myMouse.set_cursor(*pygame.cursors.arrow) pass elif event.type == pygame.MOUSEBUTTONDOWN: if self.myMouse.get_pressed() == (1, 0, 0): self.ClickAddButton( ) #check if addBUtton is clicked, display addTaskUI if such event happens self.ClickClearButton( ) #check if ClearButton is Cliked, display a query message if user wants to delete all tasks if self.addTask == True: self.getTask = self.ClickGetTask( ) #respomsibe for getting the title self.ClickGetType( ) #reponsible for getting the type if self.ClickGetTime( self.UnfixedWidget[-1].durationbuttonhh, self.UnfixedWidget[-1].durationbuttonmm ) == True: self.addState = 1 #update addState to 1->getting duration elif self.UnfixedWidget[-1].fixrbut.type == "fix": if self.ClickGetTime( self.UnfixedWidget[-1].mustarthh, self. UnfixedWidget[-1].mustartmm) == True: self.addState = 2 #update elif self.UnfixedWidget[ -1].fixrbut.type == "flexible": if self.ClickGetTime( self.UnfixedWidget[-1].lowerboundhh, self.UnfixedWidget[-1].lowerboundmm ) == True: self.addState = 3 elif self.ClickGetTime( self.UnfixedWidget[-1].upperboundhh, self.UnfixedWidget[-1].upperboundmm ) == True: self.addState = 4 elif self.clickGetPriority(): print "getting priority" self.addState = 5 self.clickGetPartition() #if self.ClickGetTime(self.UnfixedWidget[-1].lowerboundhh,self.UnfixedWidget[-1].lowerboundmm)==True: # self.addState=3 #if self.ClickGetTime(self.UnfixedWidget[-1].lowerboundhh,self.UnfixedWidget[-1].lowerboundmm)==True: # self.addState=3 else: self.addState = None self.cancelAdd() self.confirmAdd() #display the taskUI if addTask is True if self.addTask == True: if self.getTask == True: self.GetTaskTitle(event) elif self.addState == 1: self.UnfixedWidget, self.getdurationcounter = util.getinputothers( self.UnfixedWidget, self.getdurationcounter, event, self.UnfixedWidget[-1].isgetDuration) if self.addState == 2: self.UnfixedWidget, self.getmustartcounter = util.getinputothers( self.UnfixedWidget, self.getmustartcounter, event, self.UnfixedWidget[-1].isgetmustart) if self.addState == 3: self.UnfixedWidget, self.getlowerboundcounter = util.getinputothers( self.UnfixedWidget, self.getlowerboundcounter, event, self.UnfixedWidget[-1].isgetlowerbound) if self.addState == 4: self.UnfixedWidget, self.getupperboundcounter = util.getinputothers( self.UnfixedWidget, self.getupperboundcounter, event, self.UnfixedWidget[-1].isgetupperbound) if self.addState == 5: self.UnfixedWidget, self.getprioritycounter = util.getpriority( self.UnfixedWidget, self.getprioritycounter, event, self.UnfixedWidget[-1].isgetpriority) #self.UnfixedWidget,self.getupperboundcounter=util.getinputothers(self.UnfixedWidget,self.getupperboundcounter,event,self.UnfixedWidget[-1].isgetupperbound) #elif self.UnfixedWidget[-1].fixrbut.type=="flexible": # self.UnfixedWidget,self.getlowerboundcounter=util.getinputothers(self.UnfixedWidget,self.getlowerboundcounter,event,self.UnfixedWidget[-1].isgetlowerbound) # self.UnfixedWidget,self.getupperboundcounter=util.getinputothers(self.UnfixedWidget,self.getupperboundcounter,event,self.UnfixedWidget[-1].isgetupperbound) # self.UnfixedWidget,self.getprioritycounter=util.getinputothers(self.UnfixedWidget,self.getprioritycounter,event,self.UnfixedWidget[-1].isgetpriority) self.drawUI() pygame.display.update() clock.tick(300) pygame.quit() quit()
def __init__(self, controller): '''Constructor''' gtk.HBox.__init__(self) self.controller = controller self.theme = controller.theme self.config = controller.config self.set_border_width(2) self.smileysCache = {} self.hasSmilies = True self.tNick = gtk.Entry(max=129) self.tNick.set_text(self.controller.msn.nick.replace('\n', ' ')) self.tNick.set_no_show_all(True) self.lNick = SmileyLabel('', self.controller.widget_style) self.lNick.set_ellipsize(pango.ELLIPSIZE_END) self.bNick = gtk.Button() self.bNick.set_relief(gtk.RELIEF_NONE) self.bNick.set_alignment(0, 0) self.bNick.add(self.lNick) iconMail = self.theme.getSmiley("(e)") #email icon self.mailButton = ImageButton(iconMail, '(0)') self.mailButton.set_relief(gtk.RELIEF_NONE) self.mailButton.set_tooltip_text(_('Click here to access your mail')) self.statusIcon = self.theme.statusToPixbuf(self.controller.msn.status) self.statusButton = ImageButton(self.statusIcon) self.controller.msn.connect('self-status-changed',\ self.update_status_icon) self.statusButton.set_relief(gtk.RELIEF_NONE) self.statusButton.set_tooltip_text(_('Click here to change your status')) self.statusMenu = StatusMenu.StatusMenu(self.controller) self.tPersonalMessage = gtk.Entry(max=129) self.tPersonalMessage.set_text(self.controller.contacts.get_message()) self.tPersonalMessage.set_no_show_all(True) self.lPersonalMessage = SmileyLabel('', self.controller.widget_style) self.lPersonalMessage.set_ellipsize(pango.ELLIPSIZE_END) self.bPersonalMessage = gtk.Button() self.bPersonalMessage.set_relief(gtk.RELIEF_NONE) self.bPersonalMessage.set_alignment(0, 0) self.bPersonalMessage.add(self.lPersonalMessage) mediaIcon = self.theme.getSmiley("(8)") #media icon # at the bottom is the code to handle starting toggled self.mediaButton = ImageToggleButton(mediaIcon) self.mediaButton.set_relief(gtk.RELIEF_NONE) try: # why, oh why, gtk must be so angry? self.mediaButton.set_tooltip_text(_('Toggle sending current playing song')) except: pass self.lMedia = gtk.Label(_("No media playing")) self.lMedia.set_ellipsize(pango.ELLIPSIZE_END) self.bMedia = gtk.Button() self.bMedia.set_relief(gtk.RELIEF_NONE) self.bMedia.set_alignment(0, 0) self.bMedia.add(self.lMedia) self.bMedia.connect('clicked', self.onMediaClicked) self.lMedia.set_no_show_all(True) self.bMedia.set_no_show_all(True) self.bNick.set_tooltip_text(_('Click here to set your nick name')) self.bPersonalMessage.set_tooltip_text(_('Click here to set your personal message')) self.bMedia.set_tooltip_text(_('Your current media')) self.image = Widgets.avatarHolder(cellDimention = 48) self.imageEventBox = gtk.EventBox() self.imageEventBox.set_events(gtk.gdk.BUTTON_PRESS_MASK) self.imageEventBox.connect('button-press-event', self.avatarClicked) self.imageEventBox.add(self.image) self.imageEventBox.set_tooltip_text(_('Click here to set your avatar')) #frame = gtk.AspectFrame() #frame.add(self.imageEventBox) if self.controller.avatar: self.image.set_from_pixbuf(self.controller.avatar.getThumb()) else: self.pixbuf = self.controller.theme.getImage('userPanel') self.image.set_from_pixbuf(self.pixbuf) self.tNick.connect('activate', self.on_nick_changed, None, False) self.tNick.connect('focus-out-event', self.on_nick_changed, True) self.bNick.connect('clicked', self.on_nick_clicked) self.tPersonalMessage.connect('activate', self.on_pm_changed, None, False) self.tPersonalMessage.connect('focus-out-event', self.on_pm_changed, True) self.bPersonalMessage.connect('clicked', self.on_pm_clicked) self.mediaButton.connect("toggled", self.onToggleMedia) self.mailButton.connect('clicked', self.onMaiButtonClicked) self.controller.msn.connect('self-personal-message-changed', self.personalMessageChanged) self.controller.msn.connect('self-nick-changed', self.selfNickChanged) self.controller.msn.connect('self-current-media-changed', self.currentMediaChanged) self.mailButton.setText('('+str(self.controller.getUnreadMails()) +')') self.controller.msn.connect('initial-mail-notification', self.updateMailCount) self.controller.msn.connect('new-mail-notification', self.updateMailCount) self.controller.msn.connect('mail-movement-notification', self.updateMailCount) self.statusButton.connect('button-press-event', self.pop_up_status_menu) self.hbox = gtk.HBox() self.pack_start(self.imageEventBox, False, False) self.vbox1 = gtk.VBox() self.vbox2 = gtk.VBox(True) self.hbox1 = gtk.HBox() self.hbox2 = gtk.HBox() self.hbox1.pack_start(self.tNick, True, True) self.hbox1.pack_start(self.bNick, True, True) self.hbox2.pack_start(self.tPersonalMessage, True, True) self.hbox2.pack_start(self.bPersonalMessage, True, True) self.hbox2.pack_start(self.bMedia, True, True) self.vbox2h1 = gtk.HBox() self.vbox2h1.pack_end(self.mailButton, True, False) self.vbox2h1aligned = gtk.Alignment(1, 0, 0, 0) self.vbox2h1aligned.add(self.vbox2h1) self.vbox2h2 = gtk.HBox() self.vbox2h2.pack_start(self.mediaButton, True, False) self.vbox2h2.pack_end(self.statusButton, True, False) self.vbox2h2aligned = gtk.Alignment(1, 0, 0, 0) self.vbox2h2aligned.add(self.vbox2h2) self.vbox2.pack_start(self.vbox2h1aligned, True, False) self.vbox2.pack_start(self.vbox2h2aligned, True, False) self.vbox1.pack_start(self.hbox1, True, False, 1) self.vbox1.pack_start(self.hbox2, True, False, 1) self.hbox.pack_start(self.vbox1, True, True) self.hbox.pack_start(self.vbox2, False, False) self.pack_start(self.hbox) self.show_all() # if in the config is active we activate it emitting the toggled signal if controller.config.user['mediaEnabled']: self.mediaButton.set_active(True) self.mediaButton.hide() try: if not DOMAIN_REGEXP.match(self.controller.userEmail.split("@")[1]): self.mailButton.hide() except Exception, e: print "error! " + str(e)
return """<ui> <menubar name="Menubar"> <menu action="FileMenu"> <menuitem action="Quit" /> </menu> </menubar> </ui>""" def destroy(self, w): self.onExit = True SaneThread.abort_threads() if self.exit_on_destroy: gtk.main_quit() def main(self): self.show() self.exit_on_destroy = True gtk.main() if __name__ == '__main__': dev = Widgets.getDevice() if not dev: print _("no devices found") sys.exit(0) m = SaneMainWindow(dev, type=gtk.WINDOW_TOPLEVEL) m.main()
def __init__(self, controller): '''Constructor''' self.tooltip = gtk.Tooltips() self.controller = controller self.theme = controller.theme self.config = controller.config gtk.HBox.__init__(self) self.set_border_width(4) self.set_spacing(2) self.smileysCache = {} self.hasSmilies = True self.tNick = gtk.Entry(max=129) self.tNick.set_text(self.controller.msn.nick) self.tNick.set_no_show_all(True) if self.config.user['useFancyLabel']: self.lNick = FancyLabel.FancyLabel(self.controller) self.lNick.set_wrap(False) else: self.lNick = SmileyLabel('', self.controller.widget_style) self.lNick.set_ellipsize(pango.ELLIPSIZE_END) self.bNick = gtk.Button() self.bNick.set_relief(gtk.RELIEF_NONE) self.bNick.set_alignment(0, 0) self.bNick.add(self.lNick) nick = self.controller.msn.nick if not self.config.user['useFancyLabel']: parser = self.controller.unifiedParser.getParser(nick, \ PangoDataType) nick = parser.get(self.hasSmilies, self.smileysCache) self.lNick.set_markup(nick) iconMail = self.theme.getSmiley("(e)") #email icon self.mailButton = ImageButton(iconMail, '(0)') self.mailButton.set_relief(gtk.RELIEF_NONE) self.tPersonalMessage = gtk.Entry() self.tPersonalMessage.set_text(self.controller.contacts.get_message()) self.tPersonalMessage.set_no_show_all(True) self.lPersonalMessage = SmileyLabel('', self.controller.widget_style) self.lPersonalMessage.set_ellipsize(pango.ELLIPSIZE_END) self.bPersonalMessage = gtk.Button() self.bPersonalMessage.set_relief(gtk.RELIEF_NONE) self.bPersonalMessage.set_alignment(0, 0) self.bPersonalMessage.add(self.lPersonalMessage) pm = self.controller.contacts.get_message() if pm != '': parser = self.controller.unifiedParser.getParser(pm, PangoDataType) pm = parser.get(self.hasSmilies, self.smileysCache) self.lPersonalMessage.set_markup(pm) else: self.lPersonalMessage.set_text('<i><' + _('Click here to set your personal message') + '></i>') mediaIcon = self.theme.getSmiley("(8)") #media icon self.mediaButton = ImageToggleButton(mediaIcon) self.mediaButton.set_relief(gtk.RELIEF_NONE) self.lMedia = gtk.Label(_("No media playing")) self.lMedia.set_ellipsize(pango.ELLIPSIZE_END) self.bMedia = gtk.Button() self.bMedia.set_relief(gtk.RELIEF_NONE) self.bMedia.set_alignment(0, 0) self.bMedia.add(self.lMedia) self.bMedia.connect('clicked', self.onMediaClicked) self.lMedia.set_no_show_all(True) self.bMedia.set_no_show_all(True) self.tooltip.set_tip(self.bNick, _('Click here to set your nick name')) self.tooltip.set_tip(self.bPersonalMessage, _('Click here to set your personal message')) self.tooltip.set_tip(self.bMedia, _('Your current media')) self.image = Widgets.avatarHolder(cellDimention = 48) self.imageEventBox = gtk.EventBox() self.imageEventBox.set_events(gtk.gdk.BUTTON_PRESS_MASK) self.imageEventBox.connect('button-press-event', self.avatarClicked) self.imageEventBox.add(self.image) if self.controller.avatar != None: self.image.set_from_pixbuf(self.controller.avatar.getThumb()) else: self.pixbuf = self.controller.theme.getImage('userPanel') self.image.set_from_pixbuf(self.pixbuf) self.tNick.connect('activate', self.on_nick_changed) self.tNick.connect('focus-out-event', self.on_nick_changed) self.bNick.connect('clicked', self.on_nick_clicked) self.tPersonalMessage.connect('activate', self.on_pm_changed) self.tPersonalMessage.connect('focus-out-event', self.on_pm_changed) self.bPersonalMessage.connect('clicked', self.on_pm_clicked) self.mediaButton.connect("toggled", self.onToggleMedia) self.mailButton.connect('clicked', self.onMaiButtonClicked) self.controller.msn.connect('self-personal-message-changed', self.personalMessageChanged) self.controller.msn.connect('self-nick-changed', self.selfNickChanged) self.controller.msn.connect('self-current-media-changed', self.currentMediaChanged) self.mailButton.setText('('+str(self.controller.getUnreadMails()) +')') self.controller.msn.connect('initial-mail-notification', self.updateMailCount) self.controller.msn.connect('new-mail-notification', self.updateMailCount) self.controller.msn.connect('mail-movement-notification', self.updateMailCount) self.hbox = gtk.HBox() self.pack_start(self.imageEventBox, False, False) self.vbox1 = gtk.VBox() self.vbox2 = gtk.VBox(True) self.hbox1 = gtk.HBox() self.hbox2 = gtk.HBox() self.hbox1.pack_start(self.tNick, True, True) self.hbox1.pack_start(self.bNick, True, True) self.hbox2.pack_start(self.tPersonalMessage, True, True) self.hbox2.pack_start(self.bPersonalMessage, True, True) self.hbox2.pack_start(self.bMedia, True, True) self.vbox2h1 = gtk.HBox() self.vbox2h1.pack_start(self.mailButton, True, True) self.vbox2h2 = gtk.HBox() self.vbox2h2.pack_start(self.mediaButton, True, True) self.vbox2.pack_start(self.vbox2h1, True, False) self.vbox2.pack_start(self.vbox2h2, True, False) self.vbox1.pack_start(self.hbox1, True, False, 1) self.vbox1.pack_start(self.hbox2, True, False, 1) self.hbox.pack_start(self.vbox1, True, True) self.hbox.pack_start(self.vbox2, False, False) self.pack_start(self.hbox) self.show_all() if controller.config.user['mediaEnabled']: self.mediaButton.set_active(True) self.mediaButton.hide() try: if not DOMAIN_REGEXP.match(self.controller.userEmail.split("@")[1]): self.mailButton.hide() except Exception, e: print "error! " + str(e)
def __init__(self, parentUI, controller, setFocus=True): gtk.HBox.__init__(self) self.set_border_width(2) self.parentUI = parentUI self.controller = controller self.config = controller.config self.lastKeyPressed = 0 self.history = [] self.historyIndex = -1 self.localAvatar = AvatarHBox(self, controller, localavatar=True) self.toolbar = ToolbarWidget(self.parentUI, controller) self.toolbar.set_style(gtk.TOOLBAR_ICONS) self.toolbar.set_small(self.config.user['smallIcons']) self.input = Widgets.inputBox() self.input.set_left_margin(6) self.input.set_right_margin(6) self.input.set_wrap_mode(gtk.WRAP_WORD_CHAR) self.sendbutton = gtk.Button(_('Send')) self.sendbutton.show() self.sendbuttonwin = gtk.EventBox() self.sendbuttonwin.add(self.sendbutton) self.input.add_child_in_window( self.sendbuttonwin, gtk.TEXT_WINDOW_TEXT, 0, 0) self.sendbutton.connect('clicked', self.message_send) self.sendbuttonwin.connect('realize', self.change_cursor) self.inputBuffer = self.input.get_buffer() self.scrollInput = gtk.ScrolledWindow() self.scrollInput.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scrollInput.add(self.input) frameInput = gtk.Frame() frameInput.set_shadow_type(gtk.SHADOW_IN) avatar_frame = gtk.AspectFrame(xalign=0.0, yalign=1.0) avatar_frame.add(self.localAvatar) avatar_frame.set_shadow_type(gtk.SHADOW_NONE) self.vbox = gtk.VBox() self.vbox.pack_start(self.toolbar, False) self.vbox.pack_start(self.scrollInput, True, True) frameInput.add(self.vbox) self.pack_start(frameInput, True, True) self.pack_start(avatar_frame, False, False) self.inputBuffer.connect('changed', self.on_changed_event) self.input.connect('key-press-event', self.on_key_press_event) self.input.connect('drag-data-received', self.on_drag_data_received) self.input.drag_dest_set(gtk.DEST_DEFAULT_MOTION | \ gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP, \ InputWidget.DND_LIST, gtk.gdk.ACTION_COPY) self.last_dropped_file = '' self.input.connect_after('message-send', self.message_send) self.input.connect_after('escape-pressed', self.on_escape_pressed_event) self.input.connect_after('map-event', self.on_input_map_event) self.input.connect('size-allocate', self.move_sendbtn) self.scrollInput.get_vadjustment().connect('value-changed', self.move_sendbtn) if setFocus: self.input.grab_focus() self.tag = None self.id_timeout = None self.parse_off = 0 self.applyAttrsToInput() self.show_all()
def buildInterface(self, interface): # Load users.dat self.users = UserManager(os.path.join(paths.CONFIG_DIR, 'users.dat')) self.currentInterface = interface lUser = gtk.Label(_('_User:'******'_Password:'******'') lStatus = gtk.Label(_('_Status:')) lUser.set_use_underline(True) lPass.set_use_underline(True) lStatus.set_use_underline(True) # Make a ListStore for users self.userListStore = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf) # User entry with combo (from ListStore) self.tUser = gtk.ComboBoxEntry(self.userListStore, 0) self.tUser.connect("changed", self.on_comboxEntry_changed) self.tUser.connect("key-release-event", self.on_comboxEntry_keyrelease) # User entry completion (from ListStore) self.userCompletion = gtk.EntryCompletion() self.userCompletion.set_model(self.userListStore) self.tUser.get_children()[0].set_completion(self.userCompletion) self.userCompletion.connect('match-selected', self.matchSelected) # Add pictures to the completion self.userPixbufCell = gtk.CellRendererPixbuf() self.userCompletion.pack_start(self.userPixbufCell) self.userCompletion.add_attribute(self.userPixbufCell, 'pixbuf', 1) self.userCompletion.set_text_column(0) # Make a ListStore for Status self.statusListStore = gtk.ListStore(gtk.gdk.Pixbuf, gobject.TYPE_STRING, gobject.TYPE_STRING) self.tStatus = gtk.ComboBox(self.statusListStore) self.statusPixbufCell = gtk.CellRendererPixbuf() self.statusTextCell = gtk.CellRendererText() self.tStatus.pack_start(self.statusPixbufCell, False) self.tStatus.pack_start(self.statusTextCell, False) self.statusPixbufCell.set_property('xalign', 0.0) self.statusPixbufCell.set_property('xpad', 5) self.statusTextCell.set_property('xalign', 0.0) self.statusTextCell.set_property('xpad', 5) self.tStatus.add_attribute(self.statusTextCell, 'text', 2) self.tStatus.add_attribute(self.statusPixbufCell, 'pixbuf', 0) self.tPass = gtk.Entry(128) self.tPass.set_visibility(False) self.tPass.connect('activate' , self.bLogin_clicked) self.tPass.connect('key-press-event', self.on_password_keypressed) lUser.set_mnemonic_widget(self.tUser) lPass.set_mnemonic_widget(self.tPass) lStatus.set_mnemonic_widget(self.tStatus) # fill the status combobox self.statusList = [] j = 0 for i in self.controller.status_ordered[ 1 ]: if i != 'offline' and i not in self.statusList: self.statusListStore\ .append([ self.controller.theme.statusToPixbuf( emesenelib.common.status_table[i]).scale_simple(20,20,gtk.gdk.INTERP_BILINEAR), i, _(self.controller.status_ordered[2][j]) ]) self.statusList.append(i) j += 1 self.tStatus.set_active(0) pixbuf = self.controller.theme.getImage('login', False) self.loginImage = Widgets.avatarHolder() self.loginImage.set_from_pixbuf(pixbuf) if not self.controller.config.glob['dontShowAvatarInLoginWindow']: self.pack_start(self.loginImage , True , False) self.fieldsBox = gtk.VBox(spacing=10) userBox = gtk.VBox(spacing=4) lUser.set_alignment(0.0, 0.5) userBox.pack_start(lUser , False , False) userBox.pack_start(self.tUser , False , False) self.fieldsBox.pack_start(userBox, False, False) passBox = gtk.VBox(spacing=4) passLBox = gtk.HBox(spacing=6) lPass.set_alignment(0.0, 0.5) passLBox.pack_start(lPass , False , False) passLBox.pack_start(self.lCaps , False , False) passBox.pack_start(passLBox , False , False) passBox.pack_start(self.tPass , False , False) self.fieldsBox.pack_start(passBox, False, False) statusBox = gtk.VBox(spacing=4) lStatus.set_alignment(0.0, 0.5) statusBox.pack_start(lStatus , False , False) statusBox.pack_end(self.tStatus, True, True) self.fieldsBox.pack_start(statusBox, False, False) fieldsAlig = gtk.Alignment(0.5, 0.5, 0.75, 0.0) fieldsAlig.add(self.fieldsBox) self.pack_start(fieldsAlig, True, False) self.lReconnectCounter = None buttonBox = gtk.HButtonBox() if interface == 'login': self.bLogin = gtk.Button(_('_Login'), gtk.STOCK_CONNECT) self.bLogin.connect('clicked' , self.bLogin_clicked) buttonBox.pack_start(self.bLogin, False, False) self.cRemember = gtk.CheckButton(_('_Remember me'), True) self.cRemember.connect('toggled' , self.on_cRemember_toggled) self.forgetMe = gtk.EventBox() self.forgetMe.set_events(gtk.gdk.BUTTON_PRESS_MASK) self.forgetMeLabel = gtk.Label('<span foreground="#0000AA">(' + \ _('Forget me') + ')</span>') self.forgetMeLabel.set_use_markup(True) self.forgetMe.add(self.forgetMeLabel) self.forgetMe.connect('button_press_event', self.onForgetMe) self.forgetMe.set_child_visible(False) self.cRememberPass = gtk.CheckButton(_('R_emember password'), True) self.cRememberPass.connect('toggled' , self.on_cRememberPass_toggled) # TODO: find a better description and get-text it self.cAutoLogin = gtk.CheckButton(_('Auto-Login'), True) self.cAutoLogin.connect('toggled' , self.on_cAutoLogin_toggled) #this fixes a bug with user config current_user = self.controller.config.getCurrentUser() if self.controller.config.glob['rememberMe'] and current_user != '': self.cRemember.set_active(True) if self.controller.config.glob['rememberMyPassword'] and current_user != '': self.cRememberPass.set_active(True) if self.controller.config.glob['autoLogin'] and current_user != '': self.cAutoLogin.set_active(True) self.checkBox = gtk.VBox(spacing=4) rememberBox = gtk.HBox(spacing=4) rememberBox.pack_start(self.cRemember , False , False) rememberBox.pack_start(self.forgetMe , False , False) self.checkBox.pack_start(rememberBox, False, False) self.checkBox.pack_start(self.cRememberPass, False, False) self.checkBox.pack_start(self.cAutoLogin, False, False) try: import locale link = "http://status.messenger.msn.com/Status.aspx?mkt=" link += locale.getlocale()[0].replace('_','-') serverStatus = gtk.LinkButton(link,_('Service Status')) self.checkBox.pack_start(serverStatus, False, False) except: # some people have really weird python installs pass checkAlig = gtk.Alignment(0.5, 0.5) checkAlig.add(self.checkBox) self.pack_start(checkAlig , True , False) serverBox = gtk.VBox(spacing=40) serverLBox = gtk.HBox(spacing=6) serverBox.pack_start(serverLBox , False , False) checkAlig1 = gtk.Alignment(0.5, 0.5) checkAlig1.add(serverBox) self.pack_start(buttonBox, True, False) self.pack_start(checkAlig1, True, False) elif interface == 'reconnect': self.fieldsBox.set_sensitive(False) self.lConnectionError = gtk.Label() self.lConnectionError.set_markup('<b>' + _('Connection error') + '</b>') self.lReconnectCounter = gtk.Label() self.bCancelReconnect = gtk.Button(_('Cancel'), gtk.STOCK_CANCEL) self.bCancelReconnect.connect('clicked', self.onCancelReconnect) self.bReconnectNow = gtk.Button(_('Reconnect now'), gtk.STOCK_CONNECT) self.bReconnectNow.connect('clicked' , self.onReconnectNow) self.pack_start(self.lConnectionError, True, False) self.pack_start(self.lReconnectCounter, True, False) buttonBox.pack_start(self.bReconnectNow, True, False) buttonBox.pack_start(self.bCancelReconnect, False, False) self.pack_start(buttonBox, True, False) elif interface == 'loading': self.fieldsBox.set_sensitive(False) pixbuf = self.controller.theme.getImage('loading', True) self.loading = gtk.image_new_from_animation(pixbuf) cancelButton = gtk.Button(_('Cancel'), gtk.STOCK_CANCEL) cancelButton.connect('clicked', self.onCancelLogin) buttonBox.pack_start(cancelButton, False, False) self.pack_start(self.loading, False, False) self.pack_start(buttonBox, True, False) # XXX: progress stuff maybe? # fill the user list self.refreshUserList() if self.users.userExists(self.controller.config.glob['lastLoggedAccount']): self.tUser.get_children()[0].set_text(self.controller.config.glob['lastLoggedAccount']) self.show_all() self.tUser.grab_focus()
def __init__(self, db, top_lvl, id_no): ''' Initialize a gui for the insertion of students infomation' INPUT: - top_lvl: the top level window -db: the databse ''' #create a root container self.top_lvl = top_lvl self.root = tk.Toplevel(top_lvl) self.root.title("New Visit") self.id_no = id_no #upper parts : display crucial infomation #Labels: to the left of the window idL = wd.LabelWidget(self.root, 0, 0, "ID") dateL = wd.LabelWidget(self.root, 0, 1, "Visit Date") startL = wd.LabelWidget(self.root, 0, 2, "Visit Start") showL = wd.LabelWidget(self.root, 0, 3, "Show/No show") topicL = wd.LabelWidget(self.root, 0, 4, "Topic") idE = wd.LabelWidget(self.root, 1, 0, id_no) idE.config(width=30) #Entries: to the right of the window dateE = wd.EntryWidget(self.root, 1, 1, "YYYY-MM-DD") startE = wd.EntryWidget(self.root, 1, 2, "HH:MM") #check button for the show showVar = tk.StringVar() showE = tk.Checkbutton(self.root, variable=showVar, onvalue="yes", offvalue="no") showE.deselect() #set the check button to offvalue showE.grid(column=1, row=3) TopicE = wd.EntryWidget(self.root, 1, 4, "Topic") TopicE.config(width=50) #time stamp for the new notes Student Comments timeStamp = db.getTimeStamp() #lower part, display long text #Visit NOTE noteL = wd.LabelWidget(self.root, 0, 5, "Visit Note") noteL.grid(columnspan=2) noteE = wd.TextWidget(self.root, 0, 6, 150, 5, "") noteE.grid(columnspan=2) noteE.append(timeStamp + " -- ") oldNote = noteE.getVal() #store the old note for comparision later #Student Comments newComments = wd.LabelWidget(self.root, 0, 7, "Student comments") newComments.config(width=50) newComments.grid(columnspan=2) comments = wd.TextWidget(self.root, 0, 8, 150, 5, "") comments.grid(columnspan=2) comments.append(timeStamp + " -- ") oldComments = comments.getVal( ) #store the old note for comparision later #observations newObservations = wd.LabelWidget(self.root, 0, 9, "Observations") newObservations.config(width=50) newObservations.grid(columnspan=2) observations = wd.TextWidget(self.root, 0, 10, 150, 5, "") observations.grid(columnspan=2) observations.append(timeStamp + " -- ") oldObservations = observations.getVal( ) #store the old note for comparision later #recommendations newRecommendations = wd.LabelWidget(self.root, 0, 11, "Recommendations") newRecommendations.config(width=50) newRecommendations.grid(columnspan=2) recommendations = wd.TextWidget(self.root, 0, 12, 150, 5, "") recommendations.grid(columnspan=2) recommendations.append(timeStamp + " -- ") oldRecommendations = observations.getVal( ) #store the old note for comparision later #Log display to the gui log = wd.LabelWidget(self.root, 0, 14, "Status", 30) log.config(width=100) #having the log display to span 2 columns log.grid(columnspan=2) def ins(): 'method to call for the Submit button' #Checking if any of the entry fields is empty nt = "" if oldNote == noteE.getVal() else noteE.getVal() comm = "" if oldComments == comments.getVal() else comments.getVal( ) obs = "" if oldObservations == observations.getVal( ) else observations.getVal() rec = "" if oldRecommendations == observations.getVal( ) else recommendations.getVal() try: #interaction witht the Database object db.insVisit(self.id_no, dateE.getVal(), startE.getVal(), showVar.get(), TopicE.getVal(), nt, comm, obs, rec) #report that the insertion is success log.set("Success") except Exception, value: #If insertion fail, report to the Log display log.set(value)