示例#1
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.mdiArea = QMdiArea(self)
        self.setCentralWidget(self.mdiArea)
        self.mainMenu = QMenuBar(self)
        self.setMenuBar(self.mainMenu)
        m = self.mainMenu.addMenu("Window")
        a = m.addAction("Cascade windows")
        a.triggered.connect(self.mdiArea.cascadeSubWindows)

        self.treePanel = QDockWidget("Дерево задач", self)
        w = QWidget(self.treePanel)
        lay = QVBoxLayout(w)
        lay.setSpacing(1)
        lay.setContentsMargins(1, 1, 1, 1)
        w.setLayout(lay)
        self.tree = TreeWidget(self.treePanel)
        lay.addWidget(self.tree)
        edit = QTextEdit(w)
        lay.addWidget(edit)

        self.treePanel.setWidget(w)
        self.tree.activated.connect(self.handle_dblclick)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.treePanel)

        self.tools = ToolBar("tools.ini", self)
        self.addToolBar(self.tools)
示例#2
0
 def __init__(self,
              parent=None,
              title="PocketPyGui",
              action=None,
              menu=None,
              tab_traversal=True,
              visible=True,
              enabled=True,
              has_sip=True,
              has_toolbar=False):
     '''\
     Arguments :
         - parent: the parent window of this CeFrame.
         - title: the title as appearing in the title bar.
         - action : a tuple ('Label', callback) .
         - menu : the title of the right menu as a string
                  if not None, the menu can be filled via the cb_menu attribute
                  after CeFrame initialization.
     '''
     Frame.__init__(self,
                    parent,
                    title,
                    tab_traversal=tab_traversal,
                    visible=visible,
                    enabled=enabled)
     self.bind(_activate=self._on_activate,
               _settingchanged=self._on_setting_changed)
     if has_toolbar:
         self.toolbar = ToolBar(self)
     else:
         self.toolbar = None
     self.__create_menubar(action, menu, has_sip)
 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)
示例#4
0
文件: main.py 项目: avivorly/dark
    def __init__(self, parent=None):
        super(AfelApp, self).__init__(parent)
        self.setGeometry(10, 10, 1000, 1200)
        # self.setStyleSheet("""
        #
        #              font-size: 200;
        #
        #         """)
        # Flags
        self.modes = {
            'outer_window': True,
            'live_mode': False
        }

        self.result_box_group = None
        self.result_box = None

        self.module_btns = []

        mainWindow = QWidget(self)
        self.setCentralWidget(mainWindow)
        mainlay = QHBoxLayout()

        mainWindow.setLayout(mainlay)

        #  load area
        btns_group = QGroupBox()
        btns_lay = QVBoxLayout()
        btns_group.setLayout(btns_lay)
        btns_lay.addStretch(1)
        self.btns_lay = btns_lay

        self.load_modules_btns()

        startbtn = QPushButton('start process')
        startbtn.clicked.connect(self.start_process)
        btns_lay.addWidget(startbtn)



        #  sandbox area
        self.sandbox = SandBox()
        self.sandboxlay = QVBoxLayout()
        # self.sandboxlay.addStretch(209)
        self.sandbox.setLayout(self.sandboxlay)

        mainlay.addWidget(btns_group,1)
        mainlay.addWidget(self.sandbox,10)

        # toolbar
        # toolbar.setIconSize(QSize(16, 16))
        self.toolbar = ToolBar(self)
        self.addToolBar(self.toolbar)
示例#5
0
	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()
示例#6
0
    def __init__(self, *args, **kwargs):

        super(MainWindow, self).__init__(*args, **kwargs)

        self.setWindowTitle("Ini Editor")
        self.initMenu()

        self.docks = []

        self.statusBar()

        self.toolbar = ToolBar()
        self.addToolBar(self.toolbar)

        self.show()
    def __init__(self):
        tk.Tk.__init__(self)
        self.filename = None
        self.origin_image = None
        self.processed_image = None
        
        self.title("Segmentation and Edge Detection")

        self.toolbar = ToolBar(master=self)
        separator = ttk.Separator(master=self)
        self.image_viewer = Viewer(master=self)

        self.toolbar.pack(pady=10)
        separator.pack(fill=tk.X, padx=20, pady=5)
        self.image_viewer.pack(fill=tk.BOTH, padx=20, pady=10, expand=1)
示例#8
0
    def __init__(self, tasksFile, parent=None):
        super(MainWindow, self).__init__(parent)
        self.mdiArea = QMdiArea(self)
        self.setCentralWidget(self.mdiArea)
        self.mainMenu = QMenuBar(self)
        self.setMenuBar(self.mainMenu)
        m = self.mainMenu.addMenu("Window")
        a = m.addAction("Cascade windows")
        a.triggered.connect(self.mdiArea.cascadeSubWindows)

        self.treePanel = QDockWidget("Дерево задач", self)
        w = QWidget(self.treePanel)
        lay = QVBoxLayout(w)
        lay.setSpacing(1)
        lay.setContentsMargins(1, 1, 1, 1)
        w.setLayout(lay)
        self.tree = TreeWidget(self.treePanel)
        lay.addWidget(self.tree)

        self.treePanel.setWidget(w)
        self.tree.activated.connect(self.handle_dblclick)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.treePanel)

        self.winsPanel = QDockWidget("Окна", self)
        self.winlist = WinList(self.winsPanel)
        self.winsPanel.setWidget(self.winlist)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.winsPanel)
        global wins
        wins = self.winsPanel

        self.tools = ToolBar("data/tools.ini", self)
        self.addToolBar(self.tools)

        model = TreeModel(tasksFile)
        self.tree.setModel(model)
        self.tree.expandAll()
        self.tree.setColumnHidden(1, True)
        self.dataPath = os.path.split(tasksFile)[0]
示例#9
0
    def initUI(self):
        #init Text edit
        self.textEdit = TextEdit(self)
        self.textEdit.textChanged.connect(self.textChanged)
        self.bTextChanged = False
        self.bTextSaved = True
        self.bCursorPosChanged = False
        #init Tool bar
        self.toolBar = ToolBar(self)
        initToolBar(self)
        #init textSplitter
        self.textSplitter = QSplitter(Qt.Horizontal, self)
        self.textSplitter.addWidget(self.textEdit)
        #init textBrowser
        self.bShowPW = False
        self.textBrowser = None
        #init timer
        self.timer = None

        #init layout
        self.centerVBox = QVBoxLayout()
        self.centerVBox.addWidget(self.textSplitter)
        self.centerVBox.addWidget(self.toolBar)
        self.centerVBox.setSpacing(0)
        self.centerVBox.setContentsMargins(0, 0, 0, 0)
        self.setLayout(self.centerVBox)

        #init tile
        self.updateWindowTitle()
        #init position
        screen = QDesktopWidget().screenGeometry()
        self.setGeometry(screen.width() / 4,
                         screen.height() / 6,
                         screen.width() / 2,
                         screen.height() * 2 / 3)
        self.show()
示例#10
0
    def __setup_layout(self):
        """One time setup of the scene."""
        if not self.__need_setup:
            return
        stat_size = self.config['pyos']['status_size'].split(',')
        tool_size = self.config['pyos']['toolbar_size'].split(',')
        layout = TableLayout(self.config.getfloat('pyos', 'card_ratio'),
                             self.config.getfloat('pyos', 'padding'),
                             tuple([float(i) for i in stat_size]),
                             tuple([float(i) for i in tool_size]))
        layout.root.reparent_to(self.root)

        hud = HUD(layout.status, tuple([float(i) for i in stat_size]),
                  self.config['font']['normal'], self.config['font']['bold'])

        toolbar = ToolBar(self.ui.bottom_center,
                          tuple([float(i) for i in tool_size]),
                          self.config['font']['bold'],
                          (self.__new_deal, self.__reset_deal, self.__undo_move,
                           self.__menu))
        game_table = Table(layout.callback)
        layout.set_table(game_table)
        self.__systems = GameSystems(game_table, layout, hud, toolbar)
        self.__need_setup = False
示例#11
0
    def __init__(self, master=None, periodeManager=None, **kwargs):
        """
        Constructeur de CalendarZone.
        @param master: master du tkinter.Frame() que cet objet est.
        @param periodeManager: le PeriodeManager pour la barre d'outil des périodes, connue dans cet objet.
        @param **kwargs: Les options d'affichages pour le tkinter.Frame() que cet objet est.
        """
        Frame.__init__(self, master, **kwargs)
        # Note : self.master est référence vers l'Application.

        self.__isBarrePeriode = False
        # Barre du haut
        self.outilBar = ToolBar(self)  # frame avec tous les boutons outils
        self.outilBar.pack(side=TOP, fill=X, expand=NO)

        # Barre du haut pour les périodes
        self.outilBarPeriode = PeriodToolBar(
            self, periodeManager)  # frame avec tous les boutons outils

        # Zone calendrier
        self.zoneDynamicCalendarFrame = ZoneAffichage(
            self
        )  # frame avec la zone d'affichage des paramètre et la zone avec les données
        self.zoneDynamicCalendarFrame.pack(side=BOTTOM, fill=BOTH, expand=YES)
示例#12
0
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()
示例#13
0
 def create_toolbar(self):
     toolbar = ToolBar(self, 'Toolbar')
     self.addToolBar(toolbar)
示例#14
0
    def interactive(self):
        """ interactive shell"""
        self.op = ShellOperations()
        self.bindings = KeyBindings()
        cat_Storage = []
        line = ""
        self.toolBar = ToolBar()
        input_History = InMemoryHistory()
        operators = ["+", "-", "*", '**', '<', ">"]
        returnShellMethods = {"tod": self.op.do_tod()}
        listofprintMethods = [
            "meow", "help", "bll", "h", "cur", "bdir", "bl", "sh", 'wc', 'get',
            'cwl', 'cdir', 'man'
        ]
        linux_Commands = WordCompleter(listofprintMethods)

        while (True):  #excute while True
            enter_commands = prompt(
                ">>",
                history=input_History,
                key_bindings_registry=self.bindings.register,
                completer=linux_Commands,
                mouse_support=True,
                get_title=self.get_title,
                get_bottom_toolbar_tokens=self.toolBar.
                get_bottom_toolbar_tokens,
                style=self.toolBar.toolBarStyle)
            store = enter_commands
            store = store.split(" ")
            if (enter_commands in returnShellMethods.keys()):
                print(returnShellMethods[enter_commands])
            if (enter_commands not in returnShellMethods.keys()) and (
                    enter_commands
                    not in listofprintMethods) and (store[0]
                                                    not in listofprintMethods):
                try:
                    exec(enter_commands)
                except Exception as Err:
                    print(Err)
            if (enter_commands == 'cl'):
                self.op.do_cl()
            if (
                    enter_commands == "exit"
            ):  #if enter_commands equal to exit then exit interactive shell
                os.system("exit")
            if (len(enter_commands) > 1) and (enter_commands[1] in operators):
                try:
                    print(eval(enter_commands))
                except Exception as err:
                    print(err)
            if (enter_commands in listofprintMethods) and (enter_commands
                                                           == "bll"):
                self.op.do_bll()
            if (enter_commands == "h") and (enter_commands
                                            in listofprintMethods):
                self.op.do_h(line)
            if (enter_commands == "cur") and (enter_commands
                                              in listofprintMethods):
                self.op.do_cur(line)
            if (enter_commands == "bdir") and (enter_commands
                                               in listofprintMethods):
                self.op.do_bdir(line)
            if (enter_commands == 'bl') and (enter_commands
                                             in listofprintMethods):
                self.op.do_bl(line)
            if (store[0] == "sh") and (store[0] in listofprintMethods):
                try:
                    self.op.do_show(store[1])
                except Exception as err:
                    self.op.do_show(line)
            if (store[0] == "wc") and (store[0] in listofprintMethods):
                try:
                    self.op.do_cw(store[1])
                except Exception as err:
                    self.op.do_cw(line)
            if (store[0] == 'get') and (store[0] in listofprintMethods):
                try:
                    self.op.do_get(store[1])
                except Exception as err:
                    self.op.do_get(line)

            if (store[0] == "cwl") and (store[0] in listofprintMethods):
                try:
                    self.op.do_cwl(store[1])
                except Exception as err:
                    self.op.do_cwl(line)
            if (store[0] == "cdir") and (store[0] in listofprintMethods):
                try:
                    self.op.do_cdir(store[1])
                except Exception as err:
                    self.op.do_cdir(line)
            if (store[0] == "help") and (store[0] in listofprintMethods):
                try:
                    self.op.do_help(store[1])
                except Exception as err:
                    self.op.do_help(line)

            if (store[0] == "meow") and (store[0] in listofprintMethods):
                if (len(store) == 1):
                    self.op.do_cat(line)

                if (len(store) == 2):
                    if (do_cat_return[0] in dir()):
                        for cat_evaluation in eval(do_cat_return[0]):
                            print(cat_evaluation)

            if (store[0] == "meow") and (store[0]
                                         in listofprintMethods) and (len(store)
                                                                     == 3):
                do_cat_return = self.op.do_cat(store)
                exec(str(do_cat_return))
 def create_toolbar(self):
     self.grid(row=0, sticky='w')
     self.toolbar = ToolBar(self)
示例#16
0
    def build(self):
        self.root = Tk()
        self.root.geometry("800x622+200+200")
        self.root.title("SecureMe")
        self.root.resizable(width=FALSE, height=FALSE)

        menubar = Menu(self.root)
        optionsmenu = Menu(menubar, tearoff=0)
        optionsmenu.add_command(label="Refresh (Ctrl+r)",
                                command=lambda: self.refresh("NONE"))
        optionsmenu.add_command(label="Exit", command=lambda: self.quitMenu())
        menubar.add_cascade(label="Options", menu=optionsmenu)
        self.root.config(menu=menubar)

        self.toolbar = ToolBar(self.root, self)

        style = Style()
        style.configure("BW.TLabel",
                        foreground="black",
                        background="slate gray",
                        borderwidth=2)

        mFrame = Frame(self.root, bg="slate gray", padx=25, pady=25)
        mFrame.pack(fill=BOTH)
        self.notebook = ttk.Notebook(mFrame, height=500, style="BW.TLabel")
        primaryFrame = Frame(self.notebook, padx=25, pady=25)
        usersFrame = Frame(self.notebook, padx=25, pady=25)
        firewallFrame = Frame(self.notebook, padx=25, pady=25)
        servicesFrame = Frame(self.notebook, padx=25, pady=25)
        processesFrame = Frame(self.notebook, padx=25, pady=25)
        self.notebook.add(primaryFrame, text='Primary')
        self.notebook.add(usersFrame, text='Users')
        self.notebook.add(firewallFrame, text='Firewall')
        self.notebook.add(servicesFrame, text='Services')
        self.notebook.add(processesFrame, text='Processes')
        self.notebook.pack(fill=X)

        self.updatebar = Frame(self.root)
        self.updatebar.pack(side=BOTTOM, fill=X)
        self.left_label = Label(self.updatebar, text="Status: None")
        self.left_label.pack(side=LEFT, fill=X)

        # Primary Panel
        primary_label = Label(primaryFrame,
                              text='Primary Settings',
                              font=self.liberation_font_15)
        primary_label.grid(row=0, column=0, columnspan=2, sticky=N + S + E + W)

        actionspanel = LabelFrame(primaryFrame,
                                  text='System Actions',
                                  padx=10,
                                  pady=10)
        actionspanel.grid(row=1, column=0, sticky=E + N, padx=25, pady=25)

        openterminal = Button(actionspanel,
                              text='Open Terminal',
                              command=lambda: self.openTerminal())
        openterminal.pack(padx=5, pady=5)

        opencontrol = Button(actionspanel,
                             text='Open Control Panel',
                             command=lambda: self.openControlPanel())
        opencontrol.pack(padx=5, pady=5)

        shutdown = Button(actionspanel,
                          text='Shutdown',
                          command=lambda: self.shutdown())
        shutdown.pack(padx=5, pady=5)

        rebootButton = Button(actionspanel,
                              text='Reboot',
                              command=lambda: self.reboot())
        rebootButton.pack(padx=5, pady=5)

        updatespanel = LabelFrame(primaryFrame,
                                  text='System Updates',
                                  padx=10,
                                  pady=10)
        updatespanel.grid(row=1, column=1, sticky=W + N, padx=25, pady=25)

        update_button = Button(updatespanel,
                               text='Basic Update',
                               command=lambda: self.basicUpdate())
        update_button.pack(padx=5, pady=5)

        upgrade_button = Button(updatespanel,
                                text='Basic Upgrade',
                                command=lambda: self.basicUpgrade())
        upgrade_button.pack(padx=5, pady=5)

        packageupdate_button = Button(updatespanel,
                                      text='Package Update',
                                      command=lambda: self.packageUpdate())
        packageupdate_button.pack(padx=5, pady=5)

        # Users Panel
        users_label = Label(usersFrame,
                            text='User Security Settings',
                            font=self.liberation_font_15)
        users_label.pack()

        editusers = Frame(usersFrame)
        editusers.pack()

        addusr = Button(editusers,
                        text='Add User...',
                        command=lambda: self.addUser())
        addusr.grid(row=0, column=0, padx=5, pady=5)

        delusr = Button(editusers,
                        text='Del User...',
                        command=lambda: self.delUser())
        delusr.grid(row=0, column=1, padx=5, pady=5)

        userpanel = LabelFrame(usersFrame, text="Users", padx=10, pady=10)
        userpanel.pack(side=TOP, fill=BOTH)

        self.uText = self.getUserText()
        self.users_listlabel = Label(userpanel,
                                     text=self.uText,
                                     padx=10,
                                     pady=10)
        self.users_listlabel.pack(side=LEFT)

        groupspanel = LabelFrame(usersFrame, text="Groups", padx=10, pady=10)
        groupspanel.pack(side=TOP, fill=BOTH)

        self.gText = self.getGroupText()
        self.groups_text = CustomText(groupspanel)
        self.groups_text.resetText(self.gText)
        self.groups_text.type(DISABLED)
        self.groups_text.pack(fill=BOTH)

        # Firewall Label
        firewall_label = Label(firewallFrame,
                               text='Firewall Settings',
                               font=self.liberation_font_15)
        firewall_label.pack()

        edFrame = Frame(firewallFrame)
        fwEnable = Button(edFrame,
                          text='Enable',
                          command=lambda: self.enableFirewall())
        fwEnable.pack(side=LEFT, padx=10, pady=10, fill=X)
        fwDisable = Button(edFrame,
                           text='Disable',
                           command=lambda: self.disableFirewall())
        fwDisable.pack(side=RIGHT, padx=10, pady=10, fill=X)
        edFrame.pack()

        firewallpanel = LabelFrame(firewallFrame,
                                   text='Firewall Status',
                                   height=100,
                                   width=450,
                                   padx=10,
                                   pady=10)
        firewallpanel.pack(side=TOP, fill=X)

        self.fText = self.getFirewallStatus()
        self.firewall_text = CustomText(firewallpanel)
        self.firewall_text.resetText(self.fText)
        self.firewall_text.type(DISABLED)
        self.firewall_text.pack(fill=X)

        # Services Pane
        services_label = Label(servicesFrame,
                               text='System Services',
                               font=self.liberation_font_15)
        services_label.pack()

        servicespanel = LabelFrame(servicesFrame,
                                   text="Services",
                                   padx=10,
                                   pady=10)
        servicespanel.pack(side=TOP, fill=BOTH)
        self.sText = self.getServicesText()
        self.services_text = CustomText(servicespanel)
        self.services_text.resetText(self.sText)
        self.services_text.type(DISABLED)
        self.services_text.pack(fill=BOTH)

        # Processes Pane
        processes_label = Label(processesFrame,
                                text='System Processes',
                                font=self.liberation_font_15)
        processes_label.pack()

        processespanel = LabelFrame(processesFrame,
                                    text='Processes',
                                    padx=10,
                                    pady=10)
        processespanel.pack(side=TOP, fill=BOTH)
        self.pText = self.getProcessesText()
        self.processes_text = CustomText(processespanel)
        self.processes_text.resetText(self.pText)
        self.processes_text.type(DISABLED)
        self.processes_text.pack(fill=BOTH)

        self.root.bind('<Control-r>', self.refresh)

        self.root.mainloop()
示例#17
0
文件: gtkui.py 项目: orther/Deluge
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()
示例#18
0
    def __init__(self):
        super(GeoLogic, self).__init__()

        self.imported_tools = load_tools("macros.gl")
        self.env = GraphicalEnv(self.imported_tools)
        self.vis = self.env.vis
        self.general_tools = GToolDict(self.imported_tools.tool_dict)
        self.keyboard_capture = None

        menu_items = (
            ("Undo", self.undo, "<Control>z"),
            ("Redo", self.redo, "<Control><Shift>z"),
            ("Reset", self.restart, "<Control>n"),
            ("Open...", self.load, "<Control>o"),
            ("Save", self.save, "<Control>s"),
            ("Save as...", self.save_as, "<Control><Shift>s"),
            ("Export SVG...", self.export_svg, "<Control><Shift>e"),
            ("Quit", self.on_exit, "<Control>q"),
        )
        gtools = (
            ComboPoint(),
            ComboLine(),
            ComboPerpLine(),
            ComboCircle(),
            ComboCircumCircle(),
            GToolMove(),
            GToolHide(),
            GToolLabel(),
            GToolReason(),
        )
        self.key_to_gtool = dict(
            (gtool.get_key_shortcut(), gtool) for gtool in gtools)

        vbox = Gtk.VBox()
        self.add(vbox)

        self.toolbar = ToolBar(menu_items, gtools, self.general_tools)
        vbox.pack_start(self.toolbar, False, False, 0)

        hpaned = Gtk.HPaned()
        vbox.add(hpaned)
        self.step_list = StepList(self.env)
        hpaned.pack1(self.step_list, False, True)

        self.viewport = Viewport(self.env, self)
        self.viewport.set_tool(ComboPoint())
        hpaned.pack2(self.viewport.darea, True, False)
        hpaned.set_position(250)

        self.viewport.click_hook = self.toolbar.entry.unselect
        self.toolbar.set_entry_unselect(self.viewport.darea.grab_focus)
        self.toolbar.change_tool_hook = self.viewport.set_tool
        self.add_accel_group(self.toolbar.accelerators)

        def update_progress_bar(done, size):
            if size == 0: self.progress_bar.set_fraction(0)
            else: self.progress_bar.set_fraction(done / size)
            return False

        def update_progress_bar_idle(done, size):
            GLib.idle_add(update_progress_bar, done, size)

        proof_checker.paralelize(progress_hook=update_progress_bar_idle)

        self.progress_bar = Gtk.ProgressBar(show_text=False)
        vbox.pack_end(self.progress_bar, False, False, 0)

        self.connect("key-press-event", self.on_key_press)
        self.connect("key-release-event", self.on_key_release)
        self.connect("delete-event", self.on_exit)
        self.resize(1000, 600)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_events(Gdk.EventMask.KEY_PRESS_MASK
                        | Gdk.EventMask.KEY_RELEASE_MASK)

        self.show_all()

        self.update_title(None)