示例#1
0
    def __init__(self, parent, menutree, **kwargs):
        tk.Menu.__init__(self, parent)
        self.parent = parent
        self.input_list = []
        self.mops = {'tearoff': 0}
        self.menubar = tk.Menu(self.parent, **self.mops)
        self.commands = kwargs['commands']

        self.build_menubar(menutree)
        self.parent.config(menu=self.menubar)
        self.enable = self._enable
        self.normal = self._enable
        self.disable = self._disable
示例#2
0
    def _menus(self):
        # menus with callback ----------------
        # duplicates the button interface
        self.menubar = tk.Menu(self.parent)
        self.transform_method = tk.IntVar()
        self.center_method = tk.IntVar()

        # File - menu
        self.filemenu = tk.Menu(self.menubar, tearoff=0)
        self.filemenu.add_command(label="Load image file",
                                  command=self._loadimage)
        self.filemenu.add_separator()
        self.filemenu.add_command(label="Exit", command=self._quit)
        self.menubar.add_cascade(label="File", menu=self.filemenu)

        # Process - menu
        self.processmenu = tk.Menu(self.menubar, tearoff=0)
        # self.processmenu.add_command(label="Center image",
        #                              command=self._center)

        self.subcent = tk.Menu(self.processmenu)
        for cent in center_methods:
            self.subcent.add_radiobutton(
                label=cent, var=self.center_method,
                val=center_methods.index(cent), command=self._center)
        self.processmenu.add_cascade(
            label="Center image",
            menu=self.subcent, underline=0)

        self.submenu = tk.Menu(self.processmenu)
        for method in Abel_methods:
            self.submenu.add_radiobutton(
                label=method, var=self.transform_method,
                val=Abel_methods.index(method), command=self._transform)
        self.processmenu.add_cascade(
            label="Inverse Abel transform",
            menu=self.submenu, underline=0)

        self.processmenu.add_command(label="Speed distribution",
                                     command=self._speed)
        self.processmenu.add_command(label="Angular distribution",
                                     command=self._anisotropy)
        self.angmenu = tk.Menu(self.processmenu)
        self.menubar.add_cascade(label="Processing", menu=self.processmenu)

        # view - menu
        self.viewmenu = tk.Menu(self.menubar, tearoff=0)
        self.viewmenu.add_command(label="Raw image", command=self._display)
        self.viewmenu.add_command(label="Inverse Abel transformed image",
                                  command=self._transform)
        self.viewmenu.add_command(label="view buttons",
                                  command=self._on_buttons)
        self.menubar.add_cascade(label="View", menu=self.viewmenu)
示例#3
0
def main():
    """Entrypoint for OS X."""
    root = tk.Tk()
    menubar = tk.Menu(root)
    filemenu = tk.Menu(menubar)
    filemenu.add_command(label="Open Browser",
                         command=lambda: open_webbrowser(port))
    menubar.add_cascade(label="File", menu=filemenu)
    root.config(menu=menubar)
    root.withdraw()
    directory = os.path.expanduser('~/.earthreader')
    repository = urllib.parse.urljoin('file://', directory)
    session_id = Session().identifier
    app.config.update(REPOSITORY=repository,
                      SESSION_ID=session_id,
                      USE_WORKER=True)
    server = create_server(app, port=0)
    port = server.effective_port
    proc = threading.Thread(target=server.run)
    proc.daemon = True
    proc.start()
    open_webbrowser(port)
    root.mainloop()
示例#4
0
    def _set_context_menu(self):
        self.context_menu = tk.Menu(self.tree, tearoff=False)

        def _map(e):
            former_sel = self.get_selection()

            def selchanged(e):
                if former_sel != self.get_selection():
                    self.context_menu.unpost()

            self.context_menu_mapped = True
            self.tree.bind('<<TreeviewSelect>>', selchanged)

        def _unmap(e):
            self.context_menu_mapped = False
            self.tree.bind('<<TreeviewSelect>>')

        self.context_menu_mapped = False
        self.context_menu.bind('<Map>', _map)
        self.context_menu.bind('<Unmap>', _unmap)

        self.context_menu.add_command(label=self.__context_menu_mkdir,
                                      command=self.mkdir)
        self.context_menu.add_command(label=self.__context_menu_download,
                                      command=self.download)
        self.context_menu.add_command(label=self.__context_menu_upload,
                                      command=self.upload)
        self.context_menu.add_command(
            label=self.__context_menu_upload_directory,
            command=self.upload_directory)
        self.context_menu.add_command(label=self.__context_menu_delete,
                                      command=self.delete)

        self.context_menu.add_command(label=self.__context_menu_goto,
                                      command=self.goto_selected)

        self.context_menu.add_command(label=self.__context_menu_properties,
                                      command=self.selected_properties)

        self.tree.bind('<Double-Button-1>', self._goto, add='+')

        if (self.tree.tk.call('tk', 'windowingsystem') == 'aqua'):
            self.tree.bind('<Button-2>', self._select_and_pop)
            self.tree.bind('<Control-Button-1>', self._select_and_pop)
        else:
            self.tree.bind('<Button-3>', self._select_and_pop)
示例#5
0
文件: fields.py 项目: wutijat/glazier
    def __init__(self, root, option):
        tk.Frame.__init__(self, root)
        self.label = tk.Label(self, text=option['prompt'])
        self.label.grid(row=0, column=0, padx=20)
        self.button = tk.Menubutton(self, text='Choose One', relief=tk.GROOVE)
        self.menu = tk.Menu(self.button)
        self.button['menu'] = self.menu
        self.select = tk.StringVar()
        for opt in option['options']:
            self.menu.add_radiobutton(label=opt['label'],
                                      variable=self.select,
                                      value=opt['value'],
                                      command=self._Update)
            if 'default' in opt:
                self.select.set(opt['value'])
                self._Update()

        self.button.grid(row=0, column=1)
示例#6
0
    def __init__(self, input_file, args_level, args_backend, args_display_view):
        """
        Constructor initializes the tkinter display with the IsyntaxFilePath.
        :param input_file: IsyntaxFilePath
        :param args_level: The requested level
        :param args_backend: The requested backend option
        """
        self._mouse_wheel_down, self._mouse_wheel_up = Constants.get_mouse_wheel()
        self._window = tk.Tk()
        if args_display_view:
            self._title = "Python iSyntax Viewer                File: {}                View: " \
                          "Display ".format(input_file)
        else:
            self._title = "Python iSyntax Viewer                File: {}                View: " \
                          "Source ".format(input_file)
        self._window.title(self._title)
        # Configuring self.windows geometry as primary monitors height and width
        self._window.geometry("{}x{}+200+100".format(str(self._window.winfo_screenwidth()),
                                                     str(self._window.winfo_screenheight())))
        self._canvas = tk.Canvas(self._window, background='black')
        
        self._canvas.pack(side='left', expand='yes', fill='both')

        self.menu = tk.Menu(self._window)
        self.menu.add_command(label="Thumbnail", command=self.show_macro_label_image)
        self.menu.add_command(label="Properties", command=self.show_properties)
        self._process_tiles = TileProcessor(input_file, args_level, args_backend, args_display_view)
        self.display_canvas()
        self.register_mouse_events()
        self._window.config(menu=self.menu)
        self._window.mainloop()  # Event processing loop
        self.macro_image_data = None
        self.label_image_data = None

        
        ######
        
        self.start=(0,0)
        self.end=(0,0)
示例#7
0
文件: tkui.py 项目: zainhub/stash
    def __init__(self, *args, **kwargs):
        ShBaseUI.__init__(self, *args, **kwargs)
        # ui
        self.tk = tkinter.Tk()
        self.tk.title("StaSh")
        self.tk.protocol("WM_DELETE_WINDOW", self.on_close)

        # fullscreen logic
        # from: https://stackoverflow.com/a/23840010
        self._fullscreen = False
        self.tk.bind_all("<F11>", self._toggle_fullscreen)

        # terminal
        self.terminal = ShTerminal(self.stash, self)

        # right click menu
        self._rc_menu = tkinter.Menu(self.tk, tearoff=0)
        self._rc_menu.add_command(label="Copy", command=self._rc_copy)
        self._rc_menu.add_command(label="Paste", command=self._rc_paste)
        self._rc_menu.add_command(label="Toggle Fullscreen",
                                  command=self._toggle_fullscreen)
        self._rc_menu.add_command(label="Quit", command=self.stash.close)
        self.tk.bind("<Button-3>",
                     self._popup_rc_menu)  # TODO: check <Button-3> portability