Python tkinter.TOP Examples

The following are 30 code examples of tkinter.TOP(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tkinter , or try the search function .
Example #1
Source File: box.py    From synthesizer with GNU Lesser General Public License v3.0 8 votes vote down vote up
def __init__(self, master):
        super().__init__(master, text="Levels", padding=4)
        self.lowest_level = Player.levelmeter_lowest
        self.pbvar_left = tk.IntVar()
        self.pbvar_right = tk.IntVar()
        pbstyle = ttk.Style()
        # pbstyle.theme_use("classic")  # clam, alt, default, classic
        pbstyle.configure("green.Vertical.TProgressbar", troughcolor="gray", background="light green")
        pbstyle.configure("yellow.Vertical.TProgressbar", troughcolor="gray", background="yellow")
        pbstyle.configure("red.Vertical.TProgressbar", troughcolor="gray", background="orange")

        ttk.Label(self, text="dB").pack(side=tkinter.TOP)
        frame = ttk.LabelFrame(self, text="L.")
        frame.pack(side=tk.LEFT)
        self.pb_left = ttk.Progressbar(frame, orient=tk.VERTICAL, length=200, maximum=-self.lowest_level,
                                       variable=self.pbvar_left, mode='determinate',
                                       style='yellow.Vertical.TProgressbar')
        self.pb_left.pack()

        frame = ttk.LabelFrame(self, text="R.")
        frame.pack(side=tk.LEFT)
        self.pb_right = ttk.Progressbar(frame, orient=tk.VERTICAL, length=200, maximum=-self.lowest_level,
                                        variable=self.pbvar_right, mode='determinate',
                                        style='yellow.Vertical.TProgressbar')
        self.pb_right.pack() 
Example #2
Source File: _backend_tk.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def __init__(self, canvas, num, window):
        FigureManagerBase.__init__(self, canvas, num)
        self.window = window
        self.window.withdraw()
        self.set_window_title("Figure %d" % num)
        self.canvas = canvas
        # If using toolmanager it has to be present when initializing the toolbar
        self.toolmanager = self._get_toolmanager()
        # packing toolbar first, because if space is getting low, last packed widget is getting shrunk first (-> the canvas)
        self.toolbar = self._get_toolbar()
        self.canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
        self._num = num

        self.statusbar = None

        if self.toolmanager:
            backend_tools.add_tools_to_manager(self.toolmanager)
            if self.toolbar:
                backend_tools.add_tools_to_container(self.toolbar)
                self.statusbar = StatusbarTk(self.window, self.toolmanager)

        self._shown = False 
Example #3
Source File: _backend_tk.py    From Mastering-Elasticsearch-7.0 with MIT License 6 votes vote down vote up
def __init__(self, canvas, num, window):
        FigureManagerBase.__init__(self, canvas, num)
        self.window = window
        self.window.withdraw()
        self.set_window_title("Figure %d" % num)
        self.canvas = canvas
        # If using toolmanager it has to be present when initializing the
        # toolbar
        self.toolmanager = self._get_toolmanager()
        # packing toolbar first, because if space is getting low, last packed
        # widget is getting shrunk first (-> the canvas)
        self.toolbar = self._get_toolbar()
        self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
        self._num = num

        self.statusbar = None

        if self.toolmanager:
            backend_tools.add_tools_to_manager(self.toolmanager)
            if self.toolbar:
                backend_tools.add_tools_to_container(self.toolbar)
                self.statusbar = StatusbarTk(self.window, self.toolmanager)

        self._shown = False 
Example #4
Source File: streams.py    From convis with GNU General Public License v3.0 6 votes vote down vote up
def mainloop(self):
        try:
            import Tkinter as tk
        except ImportError:
            import tkinter as tk
        from PIL import Image, ImageTk
        from ttk import Frame, Button, Style
        import time
        import socket
        self.root = tk.Toplevel() #Tk()
        self.root.title('Display')
        self.image = Image.fromarray(np.zeros((200,200))).convert('RGB')
        self.image1 = ImageTk.PhotoImage(self.image)
        self.panel1 = tk.Label(self.root, image=self.image1)
        self.display = self.image1
        self.frame1 = Frame(self.root, height=50, width=50)
        self.panel1.pack(side=tk.TOP, fill=tk.BOTH, expand=tk.YES)
        self.root.after(100, self.advance_image)
        self.root.after(100, self.update_image)
        self.root.protocol("WM_DELETE_WINDOW", self.on_closing)
        #global _started_tkinter_main_loop
        #if not _started_tkinter_main_loop:
        #    _started_tkinter_main_loop = True
        #    print("Starting Tk main thread...") 
Example #5
Source File: voyagerimb.py    From voyagerimb with MIT License 6 votes vote down vote up
def view_init(self):
        self.frame = tk.LabelFrame(self.browser.workframe, text=" Image ")
        self.frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=7, pady=7)
        self.figure = plt.figure(figsize=(8, 12), dpi=70)
        self.ax1 = plt.subplot2grid((50,40), (0, 0), rowspan=40, colspan=40)
        self.ax2 = plt.subplot2grid((50,40), (42, 0), rowspan=8, colspan=40, sharex=self.ax1)
        plt.subplots_adjust(left=0.1, bottom=0.05, right=0.95, top=0.97, wspace=0.2, hspace=0.2)
        self.view_plot_image()
        self.canvas = FigureCanvasTkAgg(self.figure, self.frame)

        if self.mpltlib3:
            self.canvas.draw()
            toolbar = NavigationToolbar2Tk(self.canvas, self.frame).update()
        else:
            self.canvas.show()
            toolbar = NavigationToolbar2TkAgg(self.canvas, self.frame).update()

        self.canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)

        self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, padx=2, pady=2, expand=True)
        self.frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=7, pady=7) 
Example #6
Source File: gui.py    From skan with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def make_figure_window(self):
        self.figure_window = tk.Toplevel(self)
        self.figure_window.wm_title('Preview')
        screen_dpi = self.figure_window.winfo_fpixels('1i')
        screen_width = self.figure_window.winfo_screenwidth()  # in pixels
        figure_width = screen_width / 2 / screen_dpi
        figure_height = 0.75 * figure_width
        self.figure = Figure(figsize=(figure_width, figure_height),
                             dpi=screen_dpi)
        ax0 = self.figure.add_subplot(221)
        axes = [self.figure.add_subplot(220 + i, sharex=ax0, sharey=ax0)
                for i in range(2, 5)]
        self.axes = np.array([ax0] + axes)
        canvas = FigureCanvasTkAgg(self.figure, master=self.figure_window)
        canvas.show()
        canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
        toolbar = NavigationToolbar2Tk(canvas, self.figure_window)
        toolbar.update()
        canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1) 
Example #7
Source File: preview.py    From faceswap with GNU General Public License v3.0 6 votes vote down vote up
def _build_frame(self, parent, config_key):
        """ Build the options frame for this command

        Parameters
        ----------
        parent: tkinter object
            The tkinter object that will hold this configuration frame
        config_key: str
            The section/plugin key for these configuration options
        """
        logger.debug("Add Config Frame")
        panel_kwargs = dict(columns=2, option_columns=2, blank_nones=False)
        frame = ttk.Frame(self)
        frame.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
        cp_options = [opt for key, opt in self._options.items() if key != "helptext"]
        ControlPanel(frame, cp_options, header_text=None, **panel_kwargs)
        self._add_actions(parent, config_key)
        logger.debug("Added Config Frame") 
Example #8
Source File: _backend_tk.py    From GraphicDesignPatternByPython with MIT License 6 votes vote down vote up
def __init__(self, canvas, num, window):
        FigureManagerBase.__init__(self, canvas, num)
        self.window = window
        self.window.withdraw()
        self.set_window_title("Figure %d" % num)
        self.canvas = canvas
        # If using toolmanager it has to be present when initializing the toolbar
        self.toolmanager = self._get_toolmanager()
        # packing toolbar first, because if space is getting low, last packed widget is getting shrunk first (-> the canvas)
        self.toolbar = self._get_toolbar()
        self.canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
        self._num = num

        self.statusbar = None

        if self.toolmanager:
            backend_tools.add_tools_to_manager(self.toolmanager)
            if self.toolbar:
                backend_tools.add_tools_to_container(self.toolbar)
                self.statusbar = StatusbarTk(self.window, self.toolmanager)

        self._shown = False 
Example #9
Source File: preview.py    From faceswap with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, tk_vars):
        logger.debug("Initializing %s: (parent: %s,  tk_vars: %s)",
                     self.__class__.__name__, parent, tk_vars)
        super().__init__(parent)
        self.pack(expand=True, fill=tk.BOTH, padx=2, pady=2)

        self._refresh_display_trigger = tk_vars["refresh"]
        self._refresh_display_trigger.trace("w", self._refresh_display_callback)
        self._display = parent.preview_display
        self._canvas = tk.Canvas(self, bd=0, highlightthickness=0)
        self._canvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
        self._displaycanvas = self._canvas.create_image(0, 0,
                                                        image=self._display.tk_image,
                                                        anchor=tk.NW)
        self.bind("<Configure>", self._resize)
        logger.debug("Initialized %s", self.__class__.__name__) 
Example #10
Source File: tkwidgets.py    From hwk-mirror with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, **kwargs):
        super().__init__(parent, highlightthickness=0, **kwargs)
       
        vscrollbar = tk.Scrollbar(self, orient=tk.VERTICAL)
        vscrollbar.pack(side=tk.RIGHT, fill=tk.Y)
      
        self.canvas = canvas = tk.Canvas(self, bd=2, highlightthickness=0,
                        yscrollcommand=vscrollbar.set)
        
        canvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
        vscrollbar.config(command=canvas.yview)
        
        canvas.xview_moveto(0)
        canvas.yview_moveto(0)

        self.interior = interior = tk.Frame(canvas)
        self.interior_id = canvas.create_window(0, 0,
            window=interior,
            anchor=tk.NW)
        
        self.interior.bind("<Configure>", self.configure_interior)
        self.canvas.bind("<Configure>", self.configure_canvas)
        self.scrollbar = vscrollbar
        self.mouse_position = 0 
Example #11
Source File: display_command.py    From faceswap with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, previewname):
        logger.debug("Initializing %s: (previewname: '%s')", self.__class__.__name__, previewname)
        ttk.Frame.__init__(self, parent)

        self.name = previewname
        get_images().resize_image(self.name, None)
        self.previewimage = get_images().previewtrain[self.name][1]

        self.canvas = tk.Canvas(self, bd=0, highlightthickness=0)
        self.canvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
        self.imgcanvas = self.canvas.create_image(0,
                                                  0,
                                                  image=self.previewimage,
                                                  anchor=tk.NW)
        self.bind("<Configure>", self.resize)
        logger.debug("Initialized %s:", self.__class__.__name__) 
Example #12
Source File: control_helper.py    From faceswap with GNU General Public License v3.0 6 votes vote down vote up
def get_group_frame(self, group):
        """ Return a new group frame """
        group = group.lower()
        if self.group_frames.get(group, None) is None:
            logger.debug("Creating new group frame for: %s", group)
            is_master = group == "_master"
            opts_frame = self.optsframe.subframe
            if is_master:
                group_frame = ttk.Frame(opts_frame, name=group.lower())
            else:
                group_frame = ttk.LabelFrame(opts_frame,
                                             text="" if is_master else group.title(),
                                             name=group.lower())

            group_frame.pack(side=tk.TOP, fill=tk.X, padx=5, pady=5, anchor=tk.NW)

            self.group_frames[group] = dict(frame=group_frame,
                                            chkbtns=self.checkbuttons_frame(group_frame))
        group_frame = self.group_frames[group]
        return group_frame 
Example #13
Source File: display_page.py    From faceswap with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, tabname, helptext):
        logger.debug("Initializing %s: (tabname: '%s', helptext: %s)",
                     self.__class__.__name__, tabname, helptext)
        ttk.Frame.__init__(self, parent)
        self.pack(fill=tk.BOTH, side=tk.TOP, anchor=tk.NW)

        self.runningtask = parent.runningtask
        self.helptext = helptext
        self.tabname = tabname

        self.vars = {"info": tk.StringVar()}
        self.add_optional_vars(self.set_vars())

        self.subnotebook = self.add_subnotebook()
        self.optsframe = self.add_options_frame()
        self.add_options_info()

        self.add_frame_separator()
        self.set_mainframe_single_tab_style()
        parent.add(self, text=self.tabname.title())
        logger.debug("Initialized %s", self.__class__.__name__,) 
Example #14
Source File: display_analysis.py    From faceswap with GNU General Public License v3.0 6 votes vote down vote up
def opts_checkbuttons(self, frame):
        """ Add the options check buttons """
        logger.debug("Building Check Buttons")

        self.add_section(frame, "Display")
        for item in ("raw", "trend", "avg", "smoothed", "outliers"):
            if item == "avg":
                text = "Show Rolling Average"
            elif item == "outliers":
                text = "Flatten Outliers"
            else:
                text = "Show {}".format(item.title())
            var = tk.BooleanVar()

            if item == self.default_view:
                var.set(True)

            self.vars[item] = var

            ctl = ttk.Checkbutton(frame, variable=var, text=text)
            ctl.pack(side=tk.TOP, padx=5, pady=5, anchor=tk.W)

            hlp = self.set_help(item)
            Tooltip(ctl, text=hlp, wraplength=200)
        logger.debug("Built Check Buttons") 
Example #15
Source File: custom_widgets.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent, debug):
        logger.debug("Initializing %s: (parent: %s, debug: %s)",
                     self.__class__.__name__, parent, debug)
        super().__init__(parent)
        self.pack(side=tk.TOP, anchor=tk.W, padx=10, pady=(2, 0),
                  fill=tk.BOTH, expand=True)
        self._console = _ReadOnlyText(self)
        rc_menu = ContextMenu(self._console)
        rc_menu.cm_bind()
        self._console_clear = get_config().tk_vars['consoleclear']
        self._set_console_clear_var_trace()
        self._debug = debug
        self._build_console()
        self._add_tags()
        logger.debug("Initialized %s", self.__class__.__name__) 
Example #16
Source File: display_analysis.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def opts_combobox(self, frame):
        """ Add the options combo boxes """
        logger.debug("Building Combo boxes")
        choices = {"Display": ("Loss", "Rate"),
                   "Scale": ("Linear", "Log")}

        for item in ["Display", "Scale"]:
            var = tk.StringVar()

            cmbframe = ttk.Frame(frame)
            cmbframe.pack(fill=tk.X, pady=5, padx=5, side=tk.TOP)
            lblcmb = ttk.Label(cmbframe,
                               text="{}:".format(item),
                               width=7,
                               anchor=tk.W)
            lblcmb.pack(padx=(0, 2), side=tk.LEFT)

            cmb = ttk.Combobox(cmbframe, textvariable=var, width=10)
            cmb["values"] = choices[item]
            cmb.current(0)
            cmb.pack(fill=tk.X, side=tk.RIGHT)

            cmd = self.optbtn_reload if item == "Display" else self.graph_scale
            var.trace("w", cmd)
            self.vars[item.lower().strip()] = var

            hlp = self.set_help(item)
            Tooltip(cmbframe, text=hlp, wraplength=200)
        logger.debug("Built Combo boxes") 
Example #17
Source File: display_analysis.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def tree_configure(self, helptext):
        """ Build a tree-view widget to hold the sessions stats """
        logger.debug("Configuring Treeview")
        self.tree.configure(yscrollcommand=self.scrollbar.set)
        self.tree.tag_configure("total", background="black", foreground="white")
        self.tree.pack(side=tk.TOP, fill=tk.X)
        self.tree.bind("<ButtonRelease-1>", self.select_item)
        Tooltip(self.tree, text=helptext, wraplength=200)
        return self.tree_columns() 
Example #18
Source File: display_analysis.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def add_label(self):
        """ Add tree-view Title """
        logger.debug("Adding Treeview title")
        lbl = ttk.Label(self.sub_frame, text="Session Stats", anchor=tk.CENTER)
        lbl.pack(side=tk.TOP, fill=tk.X, padx=5, pady=5) 
Example #19
Source File: menu.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent):
        super().__init__(parent)
        self._config = get_config()
        self.pack(side=tk.TOP, anchor=tk.W, fill=tk.X, expand=False)
        self._btn_frame = ttk.Frame(self)
        self._btn_frame.pack(side=tk.TOP, pady=2, anchor=tk.W, fill=tk.X, expand=False)

        self._project_btns()
        self._group_separator()
        self._task_btns()
        self._group_separator()
        self._settings_btns()
        self._section_separator() 
Example #20
Source File: controller.py    From Jacinle with MIT License 5 votes vote down vote up
def __create_tk(self):
        self.tk_root = tk.Tk()
        self.tk_root.title(self.__title)

        self.__update_image()
        self.tk_canv = tk.Label(self.tk_root, image=self.tk_image, bd=0)
        self.tk_canv.pack(side=tk.TOP, expand=tk.YES, fill=tk.BOTH)
        self.tk_canv.focus_set()
        self.tk_canv.bind("<KeyPress>", self.__press)
        self.tk_canv.bind("<KeyRelease>", self.__release) 
Example #21
Source File: soundplayer.py    From synthesizer with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __init__(self, audio_source, master=None):
        self.lowest_level = -50
        self.have_started_playing = False
        super().__init__(master)
        self.master.title("Levels")

        self.pbvar_left = tk.IntVar()
        self.pbvar_right = tk.IntVar()
        pbstyle = ttk.Style()
        pbstyle.theme_use("classic")
        pbstyle.configure("green.Vertical.TProgressbar", troughcolor="gray", background="light green")
        pbstyle.configure("yellow.Vertical.TProgressbar", troughcolor="gray", background="yellow")
        pbstyle.configure("red.Vertical.TProgressbar", troughcolor="gray", background="orange")

        frame = tk.LabelFrame(self, text="Left")
        frame.pack(side=tk.LEFT)
        tk.Label(frame, text="dB").pack()
        self.pb_left = ttk.Progressbar(frame, orient=tk.VERTICAL, length=300,
                                       maximum=-self.lowest_level, variable=self.pbvar_left,
                                       mode='determinate', style='yellow.Vertical.TProgressbar')
        self.pb_left.pack()

        frame = tk.LabelFrame(self, text="Right")
        frame.pack(side=tk.LEFT)
        tk.Label(frame, text="dB").pack()
        self.pb_right = ttk.Progressbar(frame, orient=tk.VERTICAL, length=300,
                                        maximum=-self.lowest_level, variable=self.pbvar_right,
                                        mode='determinate', style='yellow.Vertical.TProgressbar')
        self.pb_right.pack()

        frame = tk.LabelFrame(self, text="Info")
        self.info = tk.Label(frame, text="", justify=tk.LEFT)
        frame.pack()
        self.info.pack(side=tk.TOP)
        self.pack()
        self.open_audio_file(audio_source)
        self.after_idle(self.update)
        self.after_idle(self.stream_audio) 
Example #22
Source File: box.py    From synthesizer with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __init__(self):
        super().__init__()
        self.config_location = appdirs.user_data_dir("PythonJukebox", "Razorvine")
        os.makedirs(self.config_location, mode=0o700, exist_ok=True)
        for family in tk.font.names():
            font = tk.font.nametofont(family)
            font["size"] = abs(font["size"]) + 1
            if family != "TkFixedFont":
                font["family"] = "helvetica"
        self.title("Jukebox   |   synthplayer lib v" + synthplayer.__version__)
        f = ttk.Frame()
        f1 = ttk.Frame(f)
        self.firstTrackFrame = TrackFrame(f1, "Track 1")
        self.secondTrackFrame = TrackFrame(f1, "Track 2")
        self.levelmeterFrame = LevelmeterFrame(f1)
        self.playlistFrame = PlaylistFrame(self, f1)
        self.firstTrackFrame.pack(side=tk.LEFT, fill=tk.Y)
        self.secondTrackFrame.pack(side=tk.LEFT, fill=tk.Y)
        self.levelmeterFrame.pack(side=tk.LEFT, fill=tk.Y)
        self.playlistFrame.pack(side=tk.LEFT, fill=tk.Y)
        f1.pack(side=tk.TOP)
        f2 = ttk.Frame(f)
        self.searchFrame = SearchFrame(self, f2)
        self.searchFrame.pack()
        f2.pack(side=tk.TOP)
        f3 = ttk.Frame(f)
        optionsFrame = ttk.Frame(f3)
        ttk.Button(optionsFrame, text="Database Config", command=self.do_database_config).pack()
        optionsFrame.pack(side=tk.LEFT)
        self.effectsFrame = EffectsFrame(self, f3)
        self.effectsFrame.pack()
        f3.pack(side=tk.TOP)
        self.statusbar = ttk.Label(f, text="<status>", relief=tk.GROOVE, anchor=tk.CENTER)
        self.statusbar.pack(fill=tk.X, expand=True)
        f.pack()
        self.player = Player(self, (self.firstTrackFrame, self.secondTrackFrame))
        self.backend = None
        self.backend_process = None
        self.show_status("Connecting to backend file service...")
        self.after(500, self.connect_backend) 
Example #23
Source File: log_window.py    From clai with MIT License 5 votes vote down vote up
def add_toolbar(self, window):
        toolbar = tk.Frame(window, bd=1, relief=tk.RAISED)
        self.autoscroll_button = tk.Checkbutton(toolbar, text="Auto Scroll", relief=tk.SOLID,
                                                var=self.autoscroll_enable)
        self.autoscroll_button.pack(pady=5)
        toolbar.pack(side=tk.TOP, fill=tk.X) 
Example #24
Source File: clai_emulator.py    From clai with MIT License 5 votes vote down vote up
def add_toolbar(self, root):
        toolbar = tk.Frame(root, bd=1, relief=tk.RAISED)
        self.add_play_button(toolbar)
        self.add_refresh_button(toolbar)
        self.add_log_button(toolbar)
        self.add_skills_selector(root, toolbar)
        self.add_loading_progress(toolbar)

        toolbar.pack(side=tk.TOP, fill=tk.X) 
Example #25
Source File: command.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def add_frame_separator(self):
        """ Add a separator between top and bottom frames """
        logger.debug("Add frame seperator")
        sep = ttk.Frame(self, height=2, relief=tk.RIDGE)
        sep.pack(fill=tk.X, pady=(5, 0), side=tk.TOP)
        logger.debug("Added frame seperator") 
Example #26
Source File: run_gui.py    From margipose with Apache License 2.0 5 votes vote down vote up
def __init__(self, dataset, device, model):
        super().__init__()

        self.dataset = dataset
        self.device = device
        self.model = model

        self.wm_title('3D pose estimation')
        self.geometry('1280x800')

        matplotlib.rcParams['savefig.format'] = 'svg'
        matplotlib.rcParams['savefig.directory'] = os.curdir

        # Variables
        self.var_cur_example = tk.StringVar()
        self.var_pred_visible = tk.IntVar(value=0)
        self.var_gt_visible = tk.IntVar(value=1)
        self.var_mpjpe = tk.StringVar(value='??')
        self.var_pck = tk.StringVar(value='??')
        self.var_aligned = tk.IntVar(value=0)
        self.var_joint = tk.StringVar(value='pelvis')

        if self.model is not None:
            self.var_pred_visible.set(1)

        global_toolbar = self._make_global_toolbar(self)
        global_toolbar.pack(side=tk.TOP, fill=tk.X)

        self.notebook = ttk.Notebook(self)
        self.notebook.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True, padx=4, pady=4)
        def on_change_tab(event):
            self.update_current_tab()
        self.notebook.bind('<<NotebookTabChanged>>', on_change_tab)

        self.tab_update_funcs = [
            self._make_overview_tab(self.notebook),
            self._make_heatmap_tab(self.notebook),
        ]

        self.current_example_index = 0 
Example #27
Source File: ULTI02.py    From mcculw with MIT License 5 votes vote down vote up
def recreate_data_frame(self):
        low_chan = self.low_chan
        high_chan = self.high_chan
        channels_per_row = 4

        new_data_frame = tk.Frame(self.results_group)

        self.data_labels = []
        row = 0
        column = 0
        # Add the labels for each channel
        for chan_num in range(low_chan, high_chan + 1):
            chan_label = tk.Label(new_data_frame, justify=tk.LEFT, padx=3)
            chan_label["text"] = "Channel " + str(chan_num)
            chan_label.grid(row=row, column=column)

            data_label = tk.Label(new_data_frame, justify=tk.LEFT, padx=3)
            data_label.grid(row=row + 1, column=column)
            self.data_labels.append(data_label)

            column += 1
            if column >= channels_per_row:
                row += 2
                column = 0

        self.data_frame.destroy()
        self.data_frame = new_data_frame
        self.data_frame.pack(side=tk.TOP) 
Example #28
Source File: display_graph.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def _init_toolbar(self):
        """ Same as original but ttk widgets and standard tool-tips used. Separator added and
            message label packed to the left """
        xmin, xmax = self.canvas.figure.bbox.intervalx
        height, width = 50, xmax-xmin
        ttk.Frame.__init__(self, master=self.window, width=int(width), height=int(height))

        sep = ttk.Frame(self, height=2, relief=tk.RIDGE)
        sep.pack(fill=tk.X, pady=(5, 0), side=tk.TOP)

        self.update()  # Make axes menu

        btnframe = ttk.Frame(self)
        btnframe.pack(fill=tk.X, padx=5, pady=5, side=tk.RIGHT)

        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                # Add a spacer; return value is unused.
                self._Spacer()
            else:
                button = self._Button(btnframe, text=text, file=image_file,
                                      command=getattr(self, callback))
                if tooltip_text is not None:
                    Tooltip(button, text=tooltip_text, wraplength=200)

        self.message = tk.StringVar(master=self)
        self._message_label = ttk.Label(master=self, textvariable=self.message)
        self._message_label.pack(side=tk.LEFT, padx=5)
        self.pack(side=tk.BOTTOM, fill=tk.X) 
Example #29
Source File: tkvt100.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def __init__(self, *args, **kw):
        global ttyFont, fontHeight, fontWidth
        ttyFont = tkFont.Font(family = 'Courier', size = 10)
        fontWidth = max(map(ttyFont.measure, string.ascii_letters+string.digits))
        fontHeight = int(ttyFont.metrics()['linespace'])
        self.width = kw.get('width', 80)
        self.height = kw.get('height', 25)
        self.callback = kw['callback']
        del kw['callback']
        kw['width'] = w = fontWidth * self.width
        kw['height'] = h = fontHeight * self.height
        Tkinter.Frame.__init__(self, *args, **kw)
        self.canvas = Tkinter.Canvas(bg='#000000', width=w, height=h)
        self.canvas.pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1)
        self.canvas.bind('<Key>', self.keyPressed)
        self.canvas.bind('<1>', lambda x: 'break')
        self.canvas.bind('<Up>', self.upPressed)
        self.canvas.bind('<Down>', self.downPressed)
        self.canvas.bind('<Left>', self.leftPressed)
        self.canvas.bind('<Right>', self.rightPressed)
        self.canvas.focus()

        self.ansiParser = ansi.AnsiParser(ansi.ColorText.WHITE, ansi.ColorText.BLACK)
        self.ansiParser.writeString = self.writeString
        self.ansiParser.parseCursor = self.parseCursor
        self.ansiParser.parseErase = self.parseErase
        #for (a, b) in colorMap.items():
        #    self.canvas.tag_config(a, foreground=b)
        #    self.canvas.tag_config('b'+a, background=b)
        #self.canvas.tag_config('underline', underline=1)

        self.x = 0 
        self.y = 0
        self.cursor = self.canvas.create_rectangle(0,0,fontWidth-1,fontHeight-1,fill='green',outline='green') 
Example #30
Source File: display_command.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def add_child(self):
        """ Add the preview label child """
        logger.debug("Adding child")
        preview = self.subnotebook_add_page(self.tabname, widget=None)
        lblpreview = ttk.Label(preview, image=get_images().previewoutput[1])
        lblpreview.pack(side=tk.TOP, anchor=tk.NW)
        Tooltip(lblpreview, text=self.helptext, wraplength=200)