def __init__(self, direction=Direction.right, loc=[50, 200]): super().__init__(direction, loc) self.pressed_keys = [] self.hp_status_bar = StatusBar(100, pg.Color("red"), [5, 10]) self.charge_status_bar = StatusBar(0, pg.Color("lightblue"), [5, 50]) self.right_direction_key = pg.K_d self.left_direction_key = pg.K_a self.controls = { Action.running: [pg.K_a, pg.K_d], Action.block: [pg.K_LSHIFT], Action.jumping: [pg.K_w], Action.crouched: [pg.K_s], Action.attack: [pg.K_SPACE] }
def _build_widgets(self): """Builds own widgets.""" self.lastActiveLayer = None self._disconnect_connect_from_to_iface() self.iface.currentLayerChanged.connect( self._disconnect_connect_from_to_iface) QgsMapLayerRegistry.instance().legendLayersAdded.connect( self._check_added_perimeter_layer) self.toolBar = ToolBar( self, self.dWName, self.iface, self.pluginDir) self.gridLayout.addWidget(self.toolBar, 0, 0, 1, 1) self.statusBar = StatusBar( self, self.dWName, self.iface, self.pluginDir) self.gridLayout.addWidget(self.statusBar, 2, 0, 1, 1) self.frame = QFrame(self) self.frame.setObjectName(u'frame') self.frame.setFrameShape(QFrame.StyledPanel) self.frame.setFrameShadow(QFrame.Raised) self.gridLayout.addWidget(self.frame, 1, 0, 1, 1) self.stackedWidget = StackedWidget( self, self.dWName, self.iface, self.pluginDir) self.gridLayout.addWidget(self.stackedWidget, 1, 0, 1, 1)
def __init__(self, master): self.master = master master.option_add('*tearOff', FALSE) master.title('Super CAOS') master.columnconfigure(0, weight=1) master.rowconfigure(0, weight=1) self.mainframe = Frame(master) # self.mainframe.grid(column=0, row=0, sticky=N+S+E+W) self.mainframe.pack(fill=BOTH, expand=True) self.logo_frame = LogoFrame(self.mainframe, 0, 0) self.global_menu = GlobalMenu(self.mainframe, 0, 1) self.method_menu = MethodMenu(self.mainframe, 0, 2) self.status_bar = StatusBar(self.mainframe, 0, 3) self.top_menu = TopMenu(self.mainframe, 1, 0) self.image_area = ImageArea(self.mainframe, 1, 1) self.overlay_menu = OverlayMenu(self.mainframe, 2, 1) self.mainframe.columnconfigure(0, weight=0, minsize=175) self.mainframe.columnconfigure(1, weight=1) self.mainframe.columnconfigure(2, weight=0, minsize=75) self.mainframe.rowconfigure(0, weight=0, minsize=75) self.mainframe.rowconfigure(1, weight=1, minsize=200) self.mainframe.rowconfigure(2, weight=1, minsize=200) self.mainframe.rowconfigure(3, weight=0, minsize=20) master.update() master.minsize(master.winfo_width(), master.winfo_height())
def __init__(self, master=None): tk.Frame.__init__(self, master, relief=tk.SUNKEN, bd=2) self.create_menubar() self.master.config(menu=self.menubar) #self.pack(side=tk.TOP, fill=tk.BOTH, expand=True) self.canvas = XCanvas(self.master, bg="white", width=900, height=540, scalewidget=False, bd=0, highlightthickness=0) self.tkcon = TkConsole(self.master, height=12, width=90, background='ivory') self.status = StatusBar(self.master) self.canvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True) self.tkcon.pack(side=tk.TOP, fill=tk.BOTH, expand=True) self.status.pack(side=tk.BOTTOM, fill=tk.X, expand=True) self.tkcon.focus_set() self.lastdir = os.environ['HOMEPATH'] self.units = [] self.title() self.status.set("Level Placer Status")
def create_widget(self): self.text_area = TextArea(self.frame1, bg=self.text_background, fg=self.text_foreground, undo=True, relief=tk.FLAT, font=(self.text_font_family, self.text_font_size), insertbackground=self.insertbackground) self.text_area.config(highlightthickness=0) self.text_area.grid(row=0, column=1, sticky='wens') self.text_area.focus_set() self.welcome(event=None) self.status_bar1 = StatusBar(self.frame2, bg="pink", width=30, height=10) self.status_bar2 = StatusBar(self.frame2, bg="orange", width=30, height=10) self.status_bar3 = StatusBar(self.frame2, bg="blue", width=30, height=10) self.status_bar4 = StatusBar(self.frame2, bg="green", width=30, height=10) self.status_bar5 = StatusBar(self.frame2, bg="purple", width=30, height=10) self.status_bar1.pack(side=tk.LEFT, fill=tk.BOTH, expand=True) self.status_bar2.pack(side=tk.LEFT, fill=tk.BOTH, expand=True) self.status_bar3.pack(side=tk.LEFT, fill=tk.BOTH, expand=True) self.status_bar4.pack(side=tk.LEFT, fill=tk.BOTH, expand=True) self.status_bar5.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
def initGui(self, screen_width, screen_height): bar_height = 30 self._statusbar = StatusBar(text=u"", panel_size=bar_height) self._toolbar = ToolBar(title=u"Toolbar", button_style=0) self._menubar = MenuBar(min_size=(screen_width, bar_height), position=(0, 0)) # Set up root widget self._rootwidget = pychan.widgets.VBox(padding=0, vexpand=1, hexpand=1) self._rootwidget.min_size = \ self._rootwidget.max_size = (screen_width, screen_height) self._rootwidget.opaque = False self._dockareas[DOCKAREA['left']] = DockArea("left") self._dockareas[DOCKAREA['right']] = DockArea("right") self._dockareas[DOCKAREA['top']] = DockArea("top") self._dockareas[DOCKAREA['bottom']] = DockArea("bottom") self._toolbarareas[DOCKAREA['left']] = pychan.widgets.VBox(margins=(0,0,0,0)) self._toolbarareas[DOCKAREA['right']] = pychan.widgets.VBox(margins=(0,0,0,0)) self._toolbarareas[DOCKAREA['top']] = pychan.widgets.HBox(margins=(0,0,0,0)) self._toolbarareas[DOCKAREA['bottom']] = pychan.widgets.HBox(margins=(0,0,0,0)) # This is where the map will be displayed self._centralwidget = pychan.widgets.VBox(vexpand=1, hexpand=1) self._centralwidget.opaque = False middle = pychan.widgets.HBox(padding=0, vexpand=1, hexpand=1) middle.opaque = False # Pychan bug? Adding a spacer instead of a container creates # a gap after the right dockarea middle.addChild(self._toolbarareas['left']) middle.addChild(self._dockareas['left']) middle.addChild(self._centralwidget) #middle.addSpacer(pychan.widgets.Spacer()) middle.addChild(self._dockareas['right']) middle.addChild(self._toolbarareas['right']) self._rootwidget.addChild(self._menubar) #self._rootwidget.addChild(self._toolbar) self._rootwidget.addChild(self._toolbarareas['top']) self._rootwidget.addChild(self._dockareas['top']) self._rootwidget.addChild(middle) self._rootwidget.addChild(self._dockareas['bottom']) self._rootwidget.addChild(self._toolbarareas['bottom']) self._rootwidget.addChild(self._statusbar) self._toolbar.setDocked(True) self.dockWidgetTo(self._toolbar, "top") self._rootwidget.show()
def __init__(self, **kwargs): super(Designer, self).__init__(**kwargs) self.root_name = "" self.popup = None self.file = "" # A count variable to give ids to generated widget self.count = 0 #This variable updates to True when ctrl is pressed self.ctrl_pressed = False #Instantiate the WidgetTree self.widget_tree = WidgetTree(self) self.widget_tree_box.add_widget(self.widget_tree) #Instantiate MenuBar self.menubar = MenuBar(designer = self, pos_hint = {'x':0,'top':1}, \ canvas_area = self.canvas_area, size_hint = (.70,None),height = 25) self.add_widget(self.menubar) #Instantiate right widgets bar # We update the same widgets bar, and dont create new instances everytime self.widgetbar = NewWidgetsMenu(self) self.rightbox.add_widget(self.widgetbar) #Initialize the keyboard and set up handlers for key press and release self.canvas_area._keyboard = Window.request_keyboard(self._keyboard_closed,self) self.canvas_area._keyboard.bind(on_key_down=self._on_keyboard_down) self.canvas_area._keyboard.bind(on_key_up = self._on_keyboard_up) # Setup canvas for highlighting with self.canvas.after: self.gcolor = Color(1, 1, 0, .25) PushMatrix() self.gtranslate = Translate(0, 0, 0) self.grotate = Rotate(0, 0, 0, 1) self.gscale = Scale(1.) self.grect = Rectangle(size=(0, 0)) PopMatrix() # Instantiate Statusbar self.status_bar = StatusBar(size_hint = (1,.05)) self.leftbox.add_widget(self.status_bar) #Show properties binding # self.widget -> updated on_touch_down in 'canvas_area' # So, whenever we have a new self.widget, we call show_properties self.bind(widget = self.show_properties) self.bind(widget = self.widget_tree.select_highlighted)
def __init__(self): """ Main window constructor """ tk.Tk.__init__(self) # constructeur de la classe parente # self.root = tk.Tk() self.title("Morg") self.geometry("800x800") self.wm_iconbitmap( r"D:\PythonWorkspace\Python_Project\Morg\Notepad.ico") self.minsize(width=600, height=600) workframe_frame = WorkFrame(self) statusbar_frame = StatusBar(self) # spacebar_frame = SpaceBar(self) # MODE Binding # MasterCommand(self, workframe_frame, statusbar_frame, spacebar_frame) self.mainloop()
def create_win(self): self.frdls = FrdLs( self.stdscr, self._frdls_info.smaxcol - self._frdls_info.smincol + 1, self._frdls_info.sminrow, self._frdls_info.smincol, self._frdls_info.smaxrow, self._frdls_info.smaxcol, self.friends, Config['color']['frdls']['fgcolor'], Config['color']['frdls']['bgcolor']) self.msgls_set[self.current_receiver] = MsgLs( self.stdscr, self._msgls_info.smaxcol - self._msgls_info.smincol + 1, self._msgls_info.sminrow, self._msgls_info.smincol, self._msgls_info.smaxrow, self._msgls_info.smaxcol, [], fgcolor=Config['color']['msgls']['fgcolor'], bgcolor=Config['color']['msgls']['bgcolor']) self.input = Input( self.stdscr, self._input_info.smaxcol - self._input_info.smincol + 1, self._input_info.sminrow, self._input_info.smincol, self._input_info.smaxrow, self._input_info.smaxcol, self.text, Config['color']['input']['fgcolor'], Config['color']['input']['bgcolor']) self.command = Command( self.stdscr, self._command_info.smaxrow - self._command_info.sminrow + 1, self._command_info.sminrow, self._command_info.smincol, self._command_info.smaxrow, self._command_info.smaxcol, self.command, Config['color']['command']['fgcolor'], Config['color']['command']['bgcolor']) self.statusbar = StatusBar(self.stdscr, 1, self._statusbar_info.smaxcol - self._statusbar_info.smincol + 1, self._statusbar_info.sminrow, self._statusbar_info.smincol, self._statusbar_info.smaxrow, self._statusbar_info.smaxcol, "NORMAL", "xxxxxx", fgcolor=curses.COLOR_BLACK, bgcolor=curses.COLOR_WHITE)
def run(): (window_size, f) = get_args() tb = TextBuffer() if f: tb.load(f) sdl2.ext.init() window = sdl2.ext.Window(WINDOW_TITLE, size=window_size) window.show() factory = sdl2.ext.SpriteFactory(sdl2.ext.SOFTWARE) font_img = factory.from_image(FONT_IMG_PATH) sdl2.SDL_SetColorKey( font_img.surface, sdl2.SDL_TRUE, sdl2.SDL_MapRGB(font_img.surface.format, COLOR_KEY_R, COLOR_KEY_G, COLOR_KEY_B)) font = sdl2.ext.BitmapFont(font_img, FONT_SIZE, mapping=FONT_MAPPING) sb = StatusBar(window, tb, font, STATUS_BAR_COLOR, (STATUS_BAR_BORDER_TOP, STATUS_BAR_BORDER_RIGHT, STATUS_BAR_BORDER_BOTTOM, STATUS_BAR_BORDER_LEFT)) ta = TextArea(window, font, tb, (TEXT_AREA_BORDER_TOP, TEXT_AREA_BORDER_RIGHT, sb.height + TEXT_AREA_BORDER_BOTTOM, TEXT_AREA_BORDER_LEFT), TEXT_AREA_LINE_SPACING) state = EditState(Editor(None, window, ta, sb)) sdl2.SDL_StartTextInput() while True: start = sdl2.SDL_GetTicks() state = state.update(sdl2.ext.get_events()) if state is None: break ticks = sdl2.SDL_GetTicks() - start if ticks < 1000 / FRAMES_PER_SECOND: sdl2.SDL_Delay((1000 / FRAMES_PER_SECOND) - ticks) sdl2.SDL_StopTextInput() sdl2.ext.quit() return 0
def __init__(self, *args, **kwargs): tk.Tk.__init__(self, *args, **kwargs) #initialize menu self.config(menu=MenuBar(self)) self.title('FIFA 17 Auto Buyer') self.geometry('950x650-5+40') self.minsize(width=650, height=450) # bind ctrl+a if(platform == 'darwin'): self.bind_class("Entry", "<Command-a>", self.selectall) else: self.bind_class("Entry", "<Control-a>", self.selectall) self.status = StatusBar(self) self.status.pack(side='bottom', fill='x') self.status.set_credits('0') self.appFrame = Application(self) self.appFrame.pack(side='top', fill='both', expand='True')
def __init__(self, master=None): Frame.__init__(self, master, relief=SUNKEN, bd=2) self.create_menubar() self.master.config(menu=self.menubar) self.pack(side=TOP, fill=BOTH, expand=True) panwin = PanedWindow(self, orient=VERTICAL, sashwidth=5, bd=0, bg='gray80', opaqueresize=0) self.canvas = XCanvas(self.master, bg="white", width=1200, height=640, x_axis=11, scalewidget=False, bd=0, highlightthickness=0) self.tkcon = TkConsole(self.master, height=12, width=90, background='ivory') self.status = StatusBar(self.master) self.canvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True) self.tkcon.pack(side=tk.TOP, fill=tk.BOTH, expand=True) self.status.pack(side=BOTTOM, fill=X, expand=False) self.tkcon.focus_set() # Put here all initializations you want to have in console # However it's better to use an initialization file for tkcon (look at tkcon.py) self.tkcon.eval('import os') self.tkcon.eval('import sys') self.tkcon.eval('from basics import *') self.status.set("%-60s %-16s %-16s", "Status line for this eda app (60 chars)", "Part2 (16c)", "Part3 (16c)")
def populate(self): for key, value in self.main.user_response.items(): if hasattr(self, key): if key in ['chain']: status_bar = StatusBar(key, **value) value = status_bar setattr(self, key, value) self.window.border() #Create a new window for the character bars contents = self.window.derwin(1, 1) self.new_line("Chain Status", contents, attributes=curses.A_UNDERLINE | curses.A_BOLD) self.new_line("", contents) if self.chain.cooldown > 0: #Chain is in cooldown. This has not been tested self.new_line("{:8}: {}".format("Maximum", self.chain.maximum), contents) self.new_line( "{:8}: {}".format("Current", self.get_counter(self.chain.current)), contents) self.new_line("{:8}: {}s".format("Cooldown", self.chain.cooldown), contents) else: #Chain in progress self.new_line("{:8}: {}".format("Current", self.chain.current), contents) self.new_line( "{:8}: {}".format("Timeout", self.get_counter(self.chain.timeout)), contents) self.new_line("{:8}: {}".format("Modifier", self.chain.modifier), contents)
def populate(self): for k, v in self.main.user_response.items(): if hasattr(self, k): if k in ['happy', 'life', 'energy', 'nerve', 'chain']: bar = StatusBar(k, **v) v = bar setattr(self, k, v) self.window.border() #Create a new window for the character bars contents = self.window.derwin(1, 1) self.new_line("Status Window", contents, attributes=curses.A_UNDERLINE | curses.A_BOLD) self.new_line("", contents) self.new_line("{:6}: {}[{}]".format("Name", self.name, self.player_id), contents) self.new_line("{:6}: {}".format("Status", self.status[0]), contents) #Life self.new_line(self.life.__str__(), contents, attributes=curses.color_pair( constants.COLOR_GREEN.index)) #Energy self.new_line(self.energy.__str__(), contents) #Nerve self.new_line(self.nerve.__str__(), contents) #Happiness self.new_line(self.happy.__str__(), contents)
def __create_widget(self): '''create gtk widget''' title_item_font_size = TITLE_FONT_SIZE option_item_font_size = CONTENT_FONT_SIZE # image init self.image_widgets["custom"] = ImageBox( app_theme.get_pixbuf("%s/pad_l%s.png" % (MODULE_NAME, self.has_touchpad_icon))) self.image_widgets["speed"] = ImageBox( app_theme.get_pixbuf("%s/pointer%s.png" % (MODULE_NAME, self.has_touchpad_icon))) self.image_widgets["double"] = ImageBox( app_theme.get_pixbuf("%s/double-click%s.png" % (MODULE_NAME, self.has_touchpad_icon))) self.image_widgets["drag"] = ImageBox( app_theme.get_pixbuf("%s/drag%s.png" % (MODULE_NAME, self.has_touchpad_icon))) self.image_widgets["double_test_1"] = app_theme.get_pixbuf( "%s/smiley00%s.png" % (MODULE_NAME, self.has_touchpad_icon)) self.image_widgets["double_test_2"] = app_theme.get_pixbuf( "%s/smiley01.png" % (MODULE_NAME)) # label init self.label_widgets["custom"] = Label( _("Custom"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["pointer_speed"] = Label( _("Pointer Speed"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["acceleration"] = Label( _("Acceleration"), text_size=option_item_font_size, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["sensitivity"] = Label( _("Sensitivity"), text_size=option_item_font_size, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["double_click"] = Label( _("Double-click"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["click_rate"] = Label( _("Frequency"), text_size=option_item_font_size, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["double_test"] = Label( _("Double-click on the smiley face to test your settings."), label_width=HSCALEBAR_WIDTH, wrap_width=HSCALEBAR_WIDTH, enable_select=False, enable_double_click=False) self.label_widgets["drag_drop"] = Label( _("Drag and Drop"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["drag_threshold"] = Label( _("Drag threshold"), text_size=option_item_font_size, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["relevant"] = Label(_("Relevant Settings"), text_size=title_item_font_size, enable_select=False, enable_double_click=False, fixed_width=180) # button init self.button_widgets["right_hand_radio"] = RadioButton( _("Right-handed"), padding_x=10) self.button_widgets["left_hand_radio"] = RadioButton(_("Left-handed"), padding_x=10) self.button_widgets["double_test"] = gtk.EventBox() # relevant settings button self.button_widgets["keyboard_setting"] = Label( "<u>%s</u>" % _("Keyboard Settings"), DynamicColor(GOTO_FG_COLOR), text_size=option_item_font_size, enable_select=False, enable_double_click=False, fixed_width=180) self.button_widgets["mouse_setting"] = Label( "<u>%s</u>" % _("Mouse Settings"), DynamicColor(GOTO_FG_COLOR), text_size=option_item_font_size, enable_select=False, enable_double_click=False, fixed_width=180) self.button_widgets["set_to_default"] = Button(_("Reset")) # container init self.container_widgets["main_vbox"] = gtk.VBox(False) self.container_widgets["statusbar"] = StatusBar() self.container_widgets["main_swindow"] = ScrolledWindow() self.container_widgets["main_hbox"] = gtk.HBox(False) self.container_widgets["left_vbox"] = gtk.VBox(False) self.container_widgets["right_vbox"] = gtk.VBox(False) self.container_widgets["custom_main_vbox"] = gtk.VBox(False) # custom self.container_widgets["custom_label_hbox"] = gtk.HBox(False) self.container_widgets["custom_button_hbox"] = gtk.HBox(False) self.container_widgets["pointer_speed_main_vbox"] = gtk.VBox( False) # pointer speed self.container_widgets["pointer_speed_label_hbox"] = gtk.HBox(False) self.container_widgets["pointer_speed_table"] = gtk.Table(2, 4, False) self.container_widgets["double_click_main_vbox"] = gtk.VBox( False) # double click self.container_widgets["double_click_label_hbox"] = gtk.HBox(False) self.container_widgets["double_click_table"] = gtk.Table(2, 4, False) self.container_widgets["drag_threshold_main_vbox"] = gtk.VBox( False) # mouse wheel self.container_widgets["drag_threshold_label_hbox"] = gtk.HBox(False) self.container_widgets["drag_threshold_table"] = gtk.Table(1, 4, False) # alignment init self.alignment_widgets["left"] = gtk.Alignment() self.alignment_widgets["right"] = gtk.Alignment() self.alignment_widgets["custom_label"] = gtk.Alignment() # custom self.alignment_widgets["custom_button"] = gtk.Alignment() self.alignment_widgets["pointer_speed_label"] = gtk.Alignment( ) # pointer speed self.alignment_widgets["pointer_speed_table"] = gtk.Alignment() self.alignment_widgets["double_click_label"] = gtk.Alignment( ) # double click self.alignment_widgets["double_click_table"] = gtk.Alignment() self.alignment_widgets["drag_threshold_label"] = gtk.Alignment( ) # mouse wheel self.alignment_widgets["drag_threshold_table"] = gtk.Alignment() self.alignment_widgets["keyboard_setting"] = gtk.Alignment() self.alignment_widgets["mouse_setting"] = gtk.Alignment() # adjust init self.adjust_widgets["pointer_speed_accel"] = gtk.Adjustment( 1.0, 1.0, 10.0, 1, 2) self.adjust_widgets["pointer_speed_sensitiv"] = gtk.Adjustment( 1, 1, 10, 1, 2) self.adjust_widgets["double_click_rate"] = gtk.Adjustment( 100, 100, 1000, 100, 200) self.adjust_widgets["drag_threshold_time"] = gtk.Adjustment( 1, 1, 10, 1, 2) # scale init self.scale_widgets["pointer_speed_accel"] = HScalebar(value_min=1.0, value_max=10.0) self.scale_widgets["pointer_speed_sensitiv"] = HScalebar(value_min=1, value_max=10) self.scale_widgets["double_click_rate"] = HScalebar(value_min=100, value_max=1000) self.scale_widgets["drag_threshold_time"] = HScalebar(value_min=1, value_max=10)
# self.work_frame.active_buffer.delete(a - 1) # self.workframe.active_buffer.insert(tk.END, "") # self.workframe.active_buffer.config(state=tk.DISABLED) # self.spacebar.focus_set() else: return if __name__ == "__main__": from workframe import WorkFrame from statusbar import StatusBar from spacebar import SpaceBar ROOT = tk.Tk() FRAME_1 = WorkFrame(ROOT) FRAME_2 = StatusBar(ROOT) FRAME_3 = SpaceBar(ROOT) FRAME_1.pack() FRAME_2.pack() FRAME_3.pack() MasterCommand(ROOT, FRAME_1, FRAME_2, FRAME_3) ROOT.mainloop()
def __init__(self): """ Constructor """ gtk.VBox.__init__(self) self.filter = RecentSeversFilter() self.filter.show() self.pack_start(self.filter, False, False) # top pane area paned = gtk.VPaned() paned.show() self.pack_start(paned) # bottom add a statusbar self.statusbar = StatusBar(self) self.pack_start(self.statusbar, False, False) # serverlist window self.serverlist = RecentServersList(self) paned.pack1(self.serverlist, True, False) #paned.add1(self.serverlist) # bottom panearea bottompane = gtk.HPaned() paned.pack2(bottompane, True, False) #paned.add2(bottompane) #left box self.playerlist = PlayerList() bottompane.pack1(self.playerlist, False, False) #right box self.detailsbox = ServerDetailBox() vbox = gtk.VBox() bottompane.pack2(vbox, True, False) buttonbox = gtk.HBox() vbox.pack_start(buttonbox, False, False) vbox.pack_start(self.detailsbox) refresh_button = gtk.Button('Refresh') refreshimage = gtk.Image() refreshimage.set_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_BUTTON) refresh_button.set_image(refreshimage) connect_button = gtk.Button('Connect') connectimage = gtk.Image() connectimage.set_from_stock(gtk.STOCK_CONNECT, gtk.ICON_SIZE_BUTTON) connect_button.set_image(connectimage) addfav_button = gtk.Button('Add to Favorites') favimage = gtk.Image() favimage.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON) addfav_button.set_image(favimage) removerecent_button = gtk.Button('Remove Server from List') removeimage = gtk.Image() removeimage.set_from_stock(gtk.STOCK_DELETE, gtk.ICON_SIZE_BUTTON) removerecent_button.set_image(removeimage) buttonbox.pack_start(refresh_button, True, True) buttonbox.pack_start(connect_button, True, True) buttonbox.pack_start(addfav_button, True, True) buttonbox.pack_start(removerecent_button, True, True) refresh_button.connect("clicked", self.onRefreshButtonClicked) connect_button.connect("clicked", self.connect_button_clicked) removerecent_button.connect("clicked", self.onRemoveRecentClicked) addfav_button.connect("clicked", self.onAddFavButtonClicked) self.show_all()
def __init__(self): """ Constructor """ gtk.VBox.__init__(self) fm = FileManager() config = fm.getConfiguration() if cfgvalues.BASIC_FILTER == config[cfgkey.OPT_FILTER]: self.filter = ServerListFilter(self) else: self.filter = AdvancedFilter(self) self.filter.show() self.pack_start(self.filter, False, False) # top pane area paned = gtk.VPaned() paned.show() self.pack_start(paned) # bottom add a statusbar self.statusbar = StatusBar(self) self.pack_start(self.statusbar, False, False) # serverlist window self.serverlist = ServerList(self) paned.pack1(self.serverlist, True, False) #paned.add1(self.serverlist) # bottom panearea bottompane = gtk.HPaned() paned.pack2(bottompane, True, False) #paned.add2(bottompane) #left box self.playerlist = PlayerList() bottompane.pack1(self.playerlist, False, False) #right box self.detailsbox = ServerDetailBox() vbox = gtk.VBox() bottompane.pack2(vbox, True, False) buttonbox = gtk.HBox() #self.detailsbox.pack_start(buttonbox, False, False) vbox.pack_start(buttonbox, False, False) vbox.pack_start(self.detailsbox) refresh_button = gtk.Button('Refresh') refreshimage = gtk.Image() refreshimage.set_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_BUTTON) refresh_button.set_image(refreshimage) connect_button = gtk.Button('Connect') connectimage = gtk.Image() connectimage.set_from_stock(gtk.STOCK_CONNECT, gtk.ICON_SIZE_BUTTON) connect_button.set_image(connectimage) addfav_button = gtk.Button('Add to Favorites') favimage = gtk.Image() favimage.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON) addfav_button.set_image(favimage) buttonbox.pack_start(refresh_button, True, True) buttonbox.pack_start(connect_button, True, True) buttonbox.pack_start(addfav_button, True, True) refresh_button.connect("clicked", self.onRefreshButtonClicked) addfav_button.connect("clicked", self.onAddFavButtonClicked) connect_button.connect("clicked", self.connect_button_clicked) self.show_all()
def __create_widget(self): '''create gtk widget''' title_item_font_size = TITLE_FONT_SIZE option_item_font_szie = CONTENT_FONT_SIZE self.label_widgets["speaker"] = Label(_("Speaker"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["microphone"] = Label(_("Microphone"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["left"] = Label(_("Left"), enable_select=False, enable_double_click=False) self.label_widgets["right"] = Label(_("Right"), enable_select=False, enable_double_click=False) self.label_widgets["speaker_port"] = Label(_("Output Port"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["speaker_volume"] = Label(_("Output Volume"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["speaker_mute"] = Label(_("Sound Enabled"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["speaker_balance"] = Label(_("Balance"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["microphone_port"] = Label(_("Input Port"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["microphone_volume"] = Label(_("Input Volume"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["microphone_mute"] = Label(_("Sound Enabled"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) ##################################### # image init self.image_widgets["balance"] = ImageBox(app_theme.get_pixbuf("%s/balance.png" % MODULE_NAME)) self.image_widgets["speaker"] = ImageBox(app_theme.get_pixbuf("%s/speaker-3.png" % MODULE_NAME)) self.image_widgets["microphone"] = ImageBox(app_theme.get_pixbuf("%s/microphone.png" % MODULE_NAME)) self.image_widgets["device"] = app_theme.get_pixbuf("%s/device.png" % MODULE_NAME) # button init self.button_widgets["balance"] = SwitchButton( inactive_disable_dpixbuf=app_theme.get_pixbuf("toggle_button/inactive_normal.png"), active_disable_dpixbuf=app_theme.get_pixbuf("toggle_button/inactive_normal.png")) self.button_widgets["speaker"] = SwitchButton( inactive_disable_dpixbuf=app_theme.get_pixbuf("toggle_button/inactive_normal.png"), active_disable_dpixbuf=app_theme.get_pixbuf("toggle_button/inactive_normal.png")) self.button_widgets["microphone"] = SwitchButton( inactive_disable_dpixbuf=app_theme.get_pixbuf("toggle_button/inactive_normal.png"), active_disable_dpixbuf=app_theme.get_pixbuf("toggle_button/inactive_normal.png")) self.button_widgets["advanced"] = Button(_("Advanced")) self.button_widgets["speaker_combo"] = ComboBox(fixed_width=HSCALEBAR_WIDTH) self.button_widgets["microphone_combo"] = ComboBox(fixed_width=HSCALEBAR_WIDTH) # container init self.container_widgets["main_vbox"] = gtk.VBox(False) self.container_widgets["statusbar"] = StatusBar() self.container_widgets["slider"] = HSlider() self.container_widgets["swin"] = ScrolledWindow() self.container_widgets["advance_set_tab_box"] = TabBox() self.container_widgets["advance_set_tab_box"].draw_title_background = self.draw_tab_title_background self.container_widgets["main_hbox"] = gtk.HBox(False) self.container_widgets["left_vbox"] = gtk.VBox(False) self.container_widgets["right_vbox"] = gtk.VBox(False) self.container_widgets["balance_hbox"] = gtk.HBox(False) self.container_widgets["speaker_main_vbox"] = gtk.VBox(False) # speaker self.container_widgets["speaker_label_hbox"] = gtk.HBox(False) self.container_widgets["speaker_table"] = gtk.Table(4, 2) self.container_widgets["microphone_main_vbox"] = gtk.VBox(False) # microphone self.container_widgets["microphone_label_hbox"] = gtk.HBox(False) self.container_widgets["microphone_table"] = gtk.Table(4, 2) # alignment init self.alignment_widgets["slider"] = gtk.Alignment() self.alignment_widgets["main_hbox"] = gtk.Alignment() self.alignment_widgets["advance_set_tab_box"] = gtk.Alignment() self.alignment_widgets["left"] = gtk.Alignment() self.alignment_widgets["right"] = gtk.Alignment() self.alignment_widgets["speaker_label"] = gtk.Alignment() # speaker self.alignment_widgets["speaker_set"] = gtk.Alignment() self.alignment_widgets["microphone_label"] = gtk.Alignment() # microphone self.alignment_widgets["microphone_set"] = gtk.Alignment() # adjust init volume_max_percent = pypulse.MAX_VOLUME_VALUE * 100 / pypulse.NORMAL_VOLUME_VALUE self.adjust_widgets["balance"] = gtk.Adjustment(0, -1.0, 1.0, 0.1, 0.2) self.adjust_widgets["speaker"] = gtk.Adjustment(0, 0, volume_max_percent, 1, 5) self.adjust_widgets["microphone"] = gtk.Adjustment(0, 0, volume_max_percent, 1, 5) # scale init self.scale_widgets["balance"] = HScalebar(value_min=-1, value_max=1, gray_progress=True) self.scale_widgets["balance"].set_magnetic_values([(0, 0.1), (1, 0.1), (2, 0.1)]) self.scale_widgets["speaker"] = HScalebar(show_value=True, format_value="%", value_min=0, value_max=volume_max_percent) self.scale_widgets["speaker"].set_magnetic_values([(0, 5), (100, 5), (volume_max_percent, 5)]) self.scale_widgets["microphone"] = HScalebar(show_value=True, format_value="%", value_min=0, value_max=volume_max_percent) self.scale_widgets["microphone"].set_magnetic_values([(0, 5), (100, 5), (volume_max_percent, 5)]) ################################### # advance set self.container_widgets["advance_input_box"] = gtk.VBox(False) self.container_widgets["advance_output_box"] = gtk.VBox(False) self.container_widgets["advance_hardware_box"] = gtk.VBox(False) self.alignment_widgets["advance_input_box"] = gtk.Alignment() self.alignment_widgets["advance_output_box"] = gtk.Alignment() self.alignment_widgets["advance_hardware_box"] = gtk.Alignment() # self.label_widgets["ad_output"] = Label(_("Choose a device for sound output:"), enable_select=False, enable_double_click=False) self.label_widgets["ad_input"] = Label(_("Choose a device for sound input:"), enable_select=False, enable_double_click=False) self.label_widgets["ad_hardware"] = Label(_("Choose a device to configure:"), enable_select=False, enable_double_click=False) # self.container_widgets["ad_output"] = gtk.VBox(False) self.container_widgets["ad_input"] = gtk.VBox(False) self.container_widgets["ad_hardware"] = gtk.VBox(False) # self.view_widgets["ad_output"] = TreeView() self.view_widgets["ad_input"] = TreeView() self.view_widgets["ad_hardware"] = TreeView()
class GtkUI(object): def __init__(self, args): self.daemon_bps = (0, 0, 0) # Setup signals try: import gnome.ui import gnome self.gnome_prog = gnome.init("Deluge", deluge.common.get_version()) self.gnome_client = gnome.ui.master_client() def on_die(*args): reactor.stop() self.gnome_client.connect("die", on_die) log.debug("GNOME session 'die' handler registered!") except Exception, e: log.warning( "Unable to register a 'die' handler with the GNOME session manager: %s", e) if deluge.common.windows_check(): from win32api import SetConsoleCtrlHandler from win32con import CTRL_CLOSE_EVENT from win32con import CTRL_SHUTDOWN_EVENT def win_handler(ctrl_type): log.debug("ctrl_type: %s", ctrl_type) if ctrl_type in (CTRL_CLOSE_EVENT, CTRL_SHUTDOWN_EVENT): reactor.stop() return 1 SetConsoleCtrlHandler(win_handler) # Attempt to register a magnet URI handler with gconf, but do not overwrite # if already set by another program. common.associate_magnet_links(False) # Make sure gtkui.conf has at least the defaults set self.config = deluge.configmanager.ConfigManager( "gtkui.conf", DEFAULT_PREFS) # We need to check on exit if it was started in classic mode to ensure we # shutdown the daemon. self.started_in_classic = self.config["classic_mode"] # Start the IPC Interface before anything else.. Just in case we are # already running. self.queuedtorrents = QueuedTorrents() self.ipcinterface = IPCInterface(args) # Initialize gdk threading gtk.gdk.threads_init() # We make sure that the UI components start once we get a core URI client.set_disconnect_callback(self.__on_disconnect) self.trackericons = TrackerIcons() self.sessionproxy = SessionProxy() # Initialize various components of the gtkui self.mainwindow = MainWindow() self.menubar = MenuBar() self.toolbar = ToolBar() self.torrentview = TorrentView() self.torrentdetails = TorrentDetails() self.sidebar = SideBar() self.filtertreeview = FilterTreeView() self.preferences = Preferences() self.systemtray = SystemTray() self.statusbar = StatusBar() self.addtorrentdialog = AddTorrentDialog() # Initalize the plugins self.plugins = PluginManager() # Late import because of setting up translations from connectionmanager import ConnectionManager # Show the connection manager self.connectionmanager = ConnectionManager() from twisted.internet.task import LoopingCall rpc_stats = LoopingCall(self.print_rpc_stats) rpc_stats.start(10) reactor.callWhenRunning(self._on_reactor_start) # Initialize gdk threading gtk.gdk.threads_enter() reactor.run() self.shutdown() gtk.gdk.threads_leave()
class GtkUI(object): def __init__(self, args): self.daemon_bps = (0, 0, 0) # Setup signals try: import gnome.ui import gnome #Suppress: Warning: Attempt to add property GnomeProgram::*** after class was initialised original_filters = warnings.filters[:] warnings.simplefilter("ignore") try: self.gnome_prog = gnome.init("Deluge", deluge.common.get_version()) finally: warnings.filters = original_filters self.gnome_client = gnome.ui.master_client() def on_die(*args): reactor.stop() self.gnome_client.connect("die", on_die) log.debug("GNOME session 'die' handler registered!") except Exception, e: log.warning( "Unable to register a 'die' handler with the GNOME session manager: %s", e) if deluge.common.windows_check(): from win32api import SetConsoleCtrlHandler from win32con import CTRL_CLOSE_EVENT from win32con import CTRL_SHUTDOWN_EVENT def win_handler(ctrl_type): log.debug("ctrl_type: %s", ctrl_type) if ctrl_type in (CTRL_CLOSE_EVENT, CTRL_SHUTDOWN_EVENT): reactor.stop() return 1 SetConsoleCtrlHandler(win_handler) if deluge.common.osx_check() and Gdk.WINDOWING == "quartz": import gtkosx_application self.osxapp = gtkosx_application.gtkosx_application_get() def on_die(*args): reactor.stop() self.osxapp.connect("NSApplicationWillTerminate", on_die) # Set process name again to fix gtk issue setproctitle(getproctitle()) # Attempt to register a magnet URI handler with gconf, but do not overwrite # if already set by another program. common.associate_magnet_links(False) # Make sure gtkui.conf has at least the defaults set self.config = deluge.configmanager.ConfigManager( "gtkui.conf", DEFAULT_PREFS) # We need to check on exit if it was started in classic mode to ensure we # shutdown the daemon. self.started_in_classic = self.config["classic_mode"] # Start the IPC Interface before anything else.. Just in case we are # already running. self.queuedtorrents = QueuedTorrents() self.ipcinterface = IPCInterface(args) # Initialize gdk threading Gdk.threads_init() GObject.threads_init() # We make sure that the UI components start once we get a core URI client.set_disconnect_callback(self.__on_disconnect) self.trackericons = TrackerIcons() self.sessionproxy = SessionProxy() # Initialize various components of the gtkui self.mainwindow = MainWindow() self.menubar = MenuBar() self.toolbar = ToolBar() self.torrentview = TorrentView() self.torrentdetails = TorrentDetails() self.sidebar = SideBar() self.filtertreeview = FilterTreeView() self.preferences = Preferences() self.systemtray = SystemTray() self.statusbar = StatusBar() self.addtorrentdialog = AddTorrentDialog() if deluge.common.osx_check() and Gdk.WINDOWING == "quartz": def nsapp_open_file(osxapp, filename): # Will be raised at app launch (python opening main script) if filename.endswith('Deluge-bin'): return True from deluge.ui.gtkui.ipcinterface import process_args process_args([filename]) self.osxapp.connect("NSApplicationOpenFile", nsapp_open_file) from menubar_osx import menubar_osx menubar_osx(self, self.osxapp) self.osxapp.ready() # Initalize the plugins self.plugins = PluginManager() # Show the connection manager self.connectionmanager = ConnectionManager() from twisted.internet.task import LoopingCall rpc_stats = LoopingCall(self.print_rpc_stats) rpc_stats.start(10) reactor.callWhenRunning(self._on_reactor_start) # Start the gtk main loop Gdk.threads_enter() reactor.run() self.shutdown() Gdk.threads_leave()
def build_ui(self): """ builds the user interface """ self.root = root = tk.Tk(className=self.settings.name.lower() ) # --> StartupWMClass = pwcode root.protocol("WM_DELETE_WINDOW", self.quit_app) # img = tk.Image('photo', file=self.icon_file) # TODO: Denne virker med tk8.6 men ikke tk8.5 # img = tk.PhotoImage(self.icon_file) root.tk.call('wm', 'iconphoto', root._w, tk.PhotoImage(file=self.icon_file)) # root.tk.call('wm','iconphoto',root._w,img) # root.iconphoto(False, img) w = 1300 # width for the Tk root h = 800 # height for the Tk root ws = root.winfo_screenwidth() hs = root.winfo_screenheight() x = (ws / 2) - (w / 2) y = (hs / 2) - (h / 2) root.geometry('%dx%d+%d+%d' % (w, h, x, y)) # root.option_add( "*font", "gothic" ) # root.option_add("*Font", "Times 20 bold") # def_font = tk.font.nametofont("TkDefaultFont") # def_font.config(size=16) self.font = tk.font.nametofont("TkDefaultFont") self.font.config( size=10 ) # WAIT: Gjør denne konfigurerbar. Også brukes av editor, eller fortsatt separat? style = theme.build_style(self.settings.colors) root.configure(bg=self.settings.colors.bg) # Avoid flashes of gray # TODO: Må endre tilsvarende på et par andre default farger (eks bakgrunn scrollbar når bytter tab) style.theme_use("pwcode") self.commander = Commander(self) # WAIT: Lag funksjon som leser ut dette auto fra commands.py root.bind("<Alt-x>", lambda x: self.run_command('show_commands')) root.bind("<Control-q>", lambda x: self.run_command('quit_app')) root.bind("<Control-o>", lambda x: self.run_command('open_file')) root.bind("<Control-O>", lambda x: self.run_command('open_folder')) root.bind("<Control-n>", lambda x: self.run_command('new_file')) root.bind("<Control-w>", lambda x: self.run_command('close_file')) root.bind("<Control-s>", lambda x: self.run_command('save_file')) root.bind("<Control-S>", lambda x: self.run_command('save_file_as')) root.bind("<Control-Tab>", self.perform_ctrl_tab, True) root.bind("<Control-Right>", lambda x: self.run_command('next_tab_in_index')) # TODO: Linje under gir FM kun på windows: _tkinter.TclError: bad event type or keysym "KP_Right" #root.bind("<Control-KP_Right>", lambda x: self.run_command('next_tab_in_index')) # on keypad root.bind("<Control-KP_6>", lambda x: self.run_command( 'next_tab_in_index')) # on keypad with num lock root.bind("<Control-Left>", lambda x: self.run_command('previous_tab_in_index')) # TODO: Linje under gir FM kun på windows: _tkinter.TclError: bad event type or keysym "KP_Left" #root.bind("<Control-KP_Left>", lambda x: self.run_command('previous_in_index')) # on keypad root.bind("<Control-KP_4>", lambda x: self.run_command( 'previous_tab_in_index')) # on keypad with num lock root.bind("<Control-plus>", lambda x: self.run_command('increase_text_font')) root.bind("<Control-minus>", lambda x: self.run_command('decrease_text_font')) root.bind("<Control-Return>", self.perform_ctrl_return, True) root.bind_class("Text", "<Control-Return>", lambda e: None) root.bind_class("Text", "<Control-k>", lambda e: None) root.bind("<Control-k>", lambda x: self.run_command('kill_process')) root.bind_class("Text", "<Alt-c>", lambda e: None) root.bind_class("Text", "<Alt_L><c>", lambda e: None) root.bind("<Alt-c>", lambda x: self.run_command('toggle_comment')) root.bind("<Alt_L><c>", lambda x: self.run_command('toggle_comment') ) # WAIT: Denne varianten for Alt-x også? # horizontal layout for the sidebar to expand / collapse panels self.paned = paned = tk.ttk.PanedWindow(root, orient=tk.HORIZONTAL) paned.pack(fill=tk.BOTH, expand=1) self.sidebar = SideBar(paned, self) paned.add(self.sidebar) self.editor_frame = EditorFrame(paned, self) paned.add(self.editor_frame) initial_status = '' self.statusbar = StatusBar(root, self, initial_status) self.statusbar.pack(fill=tk.X, side=tk.BOTTOM)