Python tkinter.Scale() Examples

The following are 30 code examples of tkinter.Scale(). 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: keyboard_gui.py    From synthesizer with GNU Lesser General Public License v3.0 7 votes vote down vote up
def __init__(self, master, gui):
        super().__init__(master, text="output: Tremolo")
        self.gui = gui
        self.input_waveform = tk.StringVar()
        self.input_waveform.set("<off>")
        self.input_rate = tk.DoubleVar()
        self.input_depth = tk.DoubleVar()
        self.input_rate.set(5)
        self.input_depth.set(80)
        row = 0
        tk.Label(self, text="waveform").grid(row=row, column=0)
        values = ["<off>", "sine", "triangle", "sawtooth", "square"]
        menu = tk.OptionMenu(self, self.input_waveform, *values)
        menu["width"] = 10
        menu.grid(row=row, column=1)
        row += 1
        tk.Label(self, text="rate").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_rate, from_=0.0, to=10.0, resolution=.1,
                 width=10, length=100).grid(row=row, column=1)
        row += 1
        tk.Label(self, text="depth").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_depth, from_=0.0, to=1.0, resolution=.02,
                 width=10, length=100).grid(row=row, column=1) 
Example #2
Source File: thresholder.py    From mxnet-lambda with Apache License 2.0 6 votes vote down vote up
def __init__(self, master, im, value=128):
        tkinter.Frame.__init__(self, master)

        self.image = im
        self.value = value

        self.canvas = tkinter.Canvas(self, width=im.size[0], height=im.size[1])
        self.backdrop = ImageTk.PhotoImage(im)
        self.canvas.create_image(0, 0, image=self.backdrop, anchor=tkinter.NW)
        self.canvas.pack()

        scale = tkinter.Scale(self, orient=tkinter.HORIZONTAL, from_=0, to=255,
                              resolution=1, command=self.update_scale,
                              length=256)
        scale.set(value)
        scale.bind("<ButtonRelease-1>", self.redraw)
        scale.pack()

        # uncomment the following line for instant feedback (might
        # be too slow on some platforms)
        # self.redraw() 
Example #3
Source File: enhancer.py    From mxnet-lambda with Apache License 2.0 6 votes vote down vote up
def __init__(self, master, image, name, enhancer, lo, hi):
        tkinter.Frame.__init__(self, master)

        # set up the image
        self.tkim = ImageTk.PhotoImage(image.mode, image.size)
        self.enhancer = enhancer(image)
        self.update("1.0")  # normalize

        # image window
        tkinter.Label(self, image=self.tkim).pack()

        # scale
        s = tkinter.Scale(self, label=name, orient=tkinter.HORIZONTAL,
                  from_=lo, to=hi, resolution=0.01,
                  command=self.update)
        s.set(self.value)
        s.pack() 
Example #4
Source File: app.py    From QM-Simulator-1D with MIT License 6 votes vote down vote up
def set_potential_sliders(self) -> None:
        """
        Set the sliders for the parameters that control
        the potential function.
        """
        for i in range(len(self.V_params)):
            self.sliders2.append(
                tk.Scale(self.window, 
                         label="change %s: " % str(self.V_params[i][0]),
                         from_=-2, to=2,
                         resolution=0.01,
                         orient=tk.HORIZONTAL,
                         length=200,
                         command=self.update_potential_by_slider
                         )
            )
            self.sliders2[i].grid(
                row=17 + self.sliders2_count + self.sliders1_count, 
                column=3, columnspan=2, 
                sticky=tk.N+tk.W+tk.E, padx=(10, 10)
            )
            self.sliders2[i].set(self.V_params[i][1])
            self.sliders2_count += 1 
Example #5
Source File: slider_gallery_frame.py    From pubgheatmap with MIT License 6 votes vote down vote up
def __init__(self, root, imagesList, final_img_size):
        super(SliderGalleryFrame, self).__init__(root)
        self.master.minsize(width=100, height=100)
        self.master.config()

        self.master.bind('<Left>', self.left_key)
        self.master.bind('<Right>', self.right_key)

        self.main_frame = tk.Frame()
        self.main_frame.pack(fill='both', expand=True)

        self.imagesList = imagesList

        self.panel = tk.Label(root, image=self.imagesList[0])
        self.panel.pack(side="bottom", fill="both", expand="yes")

        self.var = tk.IntVar()
        self.scale = tk.Scale(root, from_=0, to=len(imagesList) - 1, variable=self.var, orient=tk.HORIZONTAL,
                         command=self.sel, width=20, length=final_img_size)
        self.scale.pack(anchor=tk.N)

        self.pack() 
Example #6
Source File: ttk.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, master=None, variable=None, from_=0, to=10, **kw):
        """Construct a horizontal LabeledScale with parent master, a
        variable to be associated with the Ttk Scale widget and its range.
        If variable is not specified, a tkinter.IntVar is created.

        WIDGET-SPECIFIC OPTIONS

            compound: 'top' or 'bottom'
                Specifies how to display the label relative to the scale.
                Defaults to 'top'.
        """
        self._label_top = kw.pop('compound', 'top') == 'top'

        Frame.__init__(self, master, **kw)
        self._variable = variable or tkinter.IntVar(master)
        self._variable.set(from_)
        self._last_valid = from_

        self.label = Label(self)
        self.scale = Scale(self, variable=self._variable, from_=from_, to=to)
        self.scale.bind('<<RangeChanged>>', self._adjust)

        # position scale and label according to the compound option
        scale_side = 'bottom' if self._label_top else 'top'
        label_side = 'top' if scale_side == 'bottom' else 'bottom'
        self.scale.pack(side=scale_side, fill='x')
        tmp = Label(self).pack(side=label_side) # place holder
        self.label.place(anchor='n' if label_side == 'top' else 's')

        # update the label as scale or variable changes
        self.__tracecb = self._variable.trace_variable('w', self._adjust)
        self.bind('<Configure>', self._adjust)
        self.bind('<Map>', self._adjust) 
Example #7
Source File: keyboard_gui.py    From synthesizer with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __init__(self, master, gui):
        super().__init__(master, text="output: Echo / Delay")
        self.input_enabled = tk.BooleanVar()
        self.input_after = tk.DoubleVar()
        self.input_after.set(0.00)
        self.input_amount = tk.IntVar()
        self.input_amount.set(6)
        self.input_delay = tk.DoubleVar()
        self.input_delay.set(0.2)
        self.input_decay = tk.DoubleVar()
        self.input_decay.set(0.7)
        row = 0
        tk.Label(self, text="enable?").grid(row=row, column=0)
        tk.Checkbutton(self, variable=self.input_enabled, selectcolor=self.cget('bg'), fg=self.cget('fg'))\
            .grid(row=row, column=1, sticky=tk.W)
        row += 1
        tk.Label(self, text="after").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_after, from_=0, to=2.0, resolution=.01,
                 width=10, length=120).grid(row=row, column=1)
        row += 1
        tk.Label(self, text="amount").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_amount, from_=1, to=10, resolution=1,
                 width=10, length=120).grid(row=row, column=1)
        row += 1
        tk.Label(self, text="delay").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_delay, from_=0.0, to=0.5, resolution=.01,
                 width=10, length=120).grid(row=row, column=1)
        row += 1
        tk.Label(self, text="decay").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_decay, from_=0.1, to=1.5, resolution=.1,
                 width=10, length=120).grid(row=row, column=1) 
Example #8
Source File: keyboard_gui.py    From synthesizer with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __init__(self, master, gui):
        super().__init__(master, text="keys: Chords / Arpeggio")
        self.gui = gui
        self.input_mode = tk.StringVar()
        self.input_mode.set("off")
        self.input_rate = tk.DoubleVar()    # duration of note triggers
        self.input_rate.set(0.2)
        self.input_ratio = tk.IntVar()   # how many % the note is on vs off
        self.input_ratio.set(100)
        row = 0
        tk.Label(self, text="Major Chords Arp").grid(row=row, column=0, columnspan=2)
        row += 1
        tk.Radiobutton(self, variable=self.input_mode, value="off", text="off", pady=0, command=self.mode_off_selected,
                       fg=self.cget('fg'), selectcolor=self.cget('bg')).grid(row=row, column=1, sticky=tk.W)
        row += 1
        tk.Radiobutton(self, variable=self.input_mode, value="chords3", text="Chords Maj. 3", pady=0,
                       fg=self.cget('fg'), selectcolor=self.cget('bg')).grid(row=row, column=1, sticky=tk.W)
        row += 1
        tk.Radiobutton(self, variable=self.input_mode, value="chords4", text="Chords Maj. 7th", pady=0,
                       fg=self.cget('fg'), selectcolor=self.cget('bg')).grid(row=row, column=1, sticky=tk.W)
        row += 1
        tk.Radiobutton(self, variable=self.input_mode, value="arpeggio3", text="Arpeggio 3", pady=0,
                       fg=self.cget('fg'), selectcolor=self.cget('bg')).grid(row=row, column=1, sticky=tk.W)
        row += 1
        tk.Radiobutton(self, variable=self.input_mode, value="arpeggio4", text="Arpeggio 7th", pady=0,
                       fg=self.cget('fg'), selectcolor=self.cget('bg')).grid(row=row, column=1, sticky=tk.W)
        row += 1
        tk.Label(self, text="rate").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_rate, from_=0.02, to=.5, resolution=.01,
                 width=10, length=100).grid(row=row, column=1)
        row += 1
        tk.Label(self, text="ratio").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_ratio, from_=1, to=100, resolution=1,
                 width=10, length=100).grid(row=row, column=1) 
Example #9
Source File: keyboard_gui.py    From synthesizer with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __init__(self, master, name, gui):
        super().__init__(master, text="ADSR Envelope "+name)
        self.input_source = tk.StringVar()
        self.input_attack = tk.DoubleVar()
        self.input_attack.set(0.05)
        self.input_decay = tk.DoubleVar()
        self.input_decay.set(0.5)
        self.input_sustain = tk.DoubleVar()
        self.input_sustain.set(0.6)
        self.input_sustain_level = tk.DoubleVar()
        self.input_sustain_level.set(0.5)
        self.input_release = tk.DoubleVar()
        self.input_release.set(0.6)
        row = 0
        tk.Label(self, text="apply to").grid(row=row, column=0, sticky=tk.E)
        values = ["<none>", "osc 1", "osc 2", "osc 3", "osc 4", "osc 5"]
        menu = tk.OptionMenu(self, self.input_source, *values)
        menu["width"] = 10
        menu.grid(row=row, column=1)
        row += 1
        tk.Label(self, text="attack").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_attack, from_=0, to=2.0, resolution=.01,
                 width=10, length=120).grid(row=row, column=1)
        row += 1
        tk.Label(self, text="decay").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_decay, from_=0, to=2.0, resolution=.01,
                 width=10, length=120).grid(row=row, column=1)
        row += 1
        tk.Label(self, text="sustain").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_sustain, from_=0.0, to=2.0, resolution=.01,
                 width=10, length=120).grid(row=row, column=1)
        row += 1
        tk.Label(self, text="sustain lvl").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_sustain_level, from_=0.0, to=1.0, resolution=.01,
                 width=10, length=120).grid(row=row, column=1)
        row += 1
        tk.Label(self, text="release").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_release, from_=0.0, to=2.0, resolution=.01,
                 width=10, length=120).grid(row=row, column=1)
        self.input_source.set("<none>") 
Example #10
Source File: Slider.py    From guizero with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(
        self, 
        master, 
        start=0, 
        end=100, 
        horizontal=True, 
        command=None, 
        grid=None, 
        align=None, 
        visible=True, 
        enabled=None, 
        width=None, 
        height=None):

        description = "[Slider] object from " + str(start) + " to " + str(end)

        # Set the direction
        self._horizontal = horizontal
        orient = HORIZONTAL if horizontal else VERTICAL

        # Create a tk Scale object within this object
        tk = Scale(master.tk, from_=start, to=end, orient=orient, command=self._command_callback)

        super(Slider, self).__init__(master, tk, description, grid, align, visible, enabled, width, height)

        self.update_command(command)

    # PROPERTIES
    # ----------------
    # Get/set the value 
Example #11
Source File: ttk.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, master=None, **kw):
        """Construct a Ttk Scale with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS

            command, from, length, orient, to, value, variable
        """
        Widget.__init__(self, master, "ttk::scale", kw) 
Example #12
Source File: gui.py    From snake with MIT License 5 votes vote down vote up
def _init_widgets(self):
        self._canvas = tk.Canvas(self,
                                 bg=self._conf.color_bg,
                                 width=self._conf.map_width,
                                 height=self._conf.map_height,
                                 highlightthickness=0)
        self._canvas.pack(side=tk.LEFT)

        if self._conf.show_info_panel:

            self._info_var = tk.StringVar()

            frm = tk.Frame(self, bg=self._conf.color_bg)
            frm.pack(side=tk.RIGHT, anchor=tk.N)

            tk.Message(frm,
                       textvariable=self._info_var,
                       fg=self._conf.color_txt,
                       bg=self._conf.color_bg,
                       font=self._conf.font_info).pack(side=tk.TOP, anchor=tk.W)

            scale = tk.Scale(frm,
                             font=self._conf.font_info,
                             fg=self._conf.color_txt,
                             bg=self._conf.color_bg,
                             highlightthickness=0,
                             from_=self._conf.interval_draw_max,
                             to=0,
                             orient=tk.HORIZONTAL,
                             length=self._conf.window_width - self._conf.map_width,
                             showvalue=False,
                             tickinterval=0,
                             resolution=1,
                             command=self._update_speed)
            scale.pack(side=tk.TOP, anchor=tk.W)
            scale.set(self._conf.interval_draw) 
Example #13
Source File: test_widgets.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def create(self, **kwargs):
        return tkinter.Scale(self.root, **kwargs) 
Example #14
Source File: test_geometry_managers.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_grid_size(self):
        with self.assertRaises(TypeError):
            self.root.grid_size(0)
        self.assertEqual(self.root.grid_size(), (0, 0))
        f = tkinter.Scale(self.root)
        f.grid_configure(row=0, column=0)
        self.assertEqual(self.root.grid_size(), (1, 1))
        f.grid_configure(row=4, column=5)
        self.assertEqual(self.root.grid_size(), (6, 5)) 
Example #15
Source File: voyagerimb.py    From voyagerimb with MIT License 5 votes vote down vote up
def __init__(self, parent):
        self.parent = parent
        self.browser = parent.browser
        self.frame = tk.LabelFrame(self.parent.frame, text=" Plot scanline ")
        self.scale = tk.Scale(self.frame, from_=0, to=self.browser.number_of_scans,
                              orient=tk.HORIZONTAL, showvalue=True, command=self.model_sync_with_entry )
        self.scale.pack(side=tk.LEFT, fill=tk.X, padx=4, pady=4, anchor=tk.CENTER, expand=True)
        self.parent.numberofscans.number_of_scans_entry.textvariable.trace("w", self.model_slide_range_update)
        tk.Button(self.frame, text="-", command=self.model_decrease).pack(side=tk.LEFT)
        tk.Button(self.frame, text="+", command=self.model_increase).pack(side=tk.LEFT)
        self.frame.pack(side=tk.TOP, fill=tk.X, padx=7, pady=7, expand=False) 
Example #16
Source File: chapter1_06.py    From Tkinter-GUI-Application-Development-Cookbook with MIT License 5 votes vote down vote up
def __init__(self):
        super().__init__()
        self.spinbox = tk.Spinbox(self, from_=0, to=5)
        self.scale = tk.Scale(self, from_=0, to=5,
                              orient=tk.HORIZONTAL)
        self.btn = tk.Button(self, text="Print values",
                             command=self.print_values)
        self.spinbox.pack()
        self.scale.pack()
        self.btn.pack() 
Example #17
Source File: chapter1_06.py    From Tkinter-GUI-Application-Development-Cookbook with MIT License 5 votes vote down vote up
def print_values(self):
        print("Spinbox: {}".format(self.spinbox.get()))
        print("Scale: {}".format(self.scale.get())) 
Example #18
Source File: app.py    From QM-Simulator-1D with MIT License 5 votes vote down vote up
def set_widgets_after_enter_wavefunction(self, init_call=False) -> None:
        """
        Set the widgets after the enter wavefunction button.
        """
        prev_sliders1_count = self.sliders1_count
        self.destroy_wavefunction_sliders()

        if len(self.psi_params) > 0:
            for i in range(len(self.psi_params)):
                self.sliders1.append(
                    tk.Scale(self.window, 
                             label="change %s: " % str(self.psi_params[i][0]),
                             from_=-2, to=2,
                             resolution=0.01,
                             orient=tk.HORIZONTAL,
                             length=200,
                             command=self.update_wavefunction_by_slider
                            )
                )
                self.sliders1[i].grid(
                    row=12 + self.sliders1_count, 
                    column=3, columnspan=2, 
                    sticky=tk.N+tk.W+tk.E, padx=(10, 10)
                )
                self.sliders1[i].set(self.psi_params[i][1])
                self.sliders1_count += 1

        if prev_sliders1_count != self.sliders1_count:
            self.set_widgets_after_wavefunction_sliders(init_call) 
Example #19
Source File: app.py    From QM-Simulator-1D with MIT License 5 votes vote down vote up
def set_widgets_after_potential_sliders(self) -> None:
        """
        Set the widgets after the parameter sliders for the potential
        """
        total_sliders_count = self.sliders2_count + self.sliders1_count
        # Animation speed slider
        if self.slider_speed_label is not None:
            self.slider_speed_label.destroy()
        self.slider_speed_label = tk.LabelFrame(
                self.window, text="Animation Speed")
        self.slider_speed_label.grid(row=17 + total_sliders_count, 
                                        column=3, padx=(10, 10))
        if self.slider_speed is not None:
            self.slider_speed.destroy()
        self.slider_speed = tk.Scale(self.slider_speed_label,
                                        from_=0, to=10,
                                        orient=tk.HORIZONTAL,
                                        length=200,
                                        command=self.change_animation_speed
                                        )
        self.slider_speed.grid(row=18 + total_sliders_count,
                                column=3, padx=(10, 10))
        self.slider_speed.set(1)
        # Quit button
        if self.quit_button is not None:
            self.quit_button.destroy()
        self.quit_button = tk.Button(
                self.window, text='QUIT', command=self.quit)
        self.quit_button.grid(row=19  + total_sliders_count, 
                                column=3) 
Example #20
Source File: playbackFrame.py    From PyEveLiveDPS with GNU General Public License v3.0 5 votes vote down vote up
def makeTimeSlider(self):
        self.timeSlider = tk.Scale(self, from_=self.startValue, to=self.endValue, orient=tk.constants.HORIZONTAL, 
                                   showvalue=0, command=self.timeChanged, bigincrement=60)
        self.timeSlider.configure(background="black", foreground="white", sliderrelief=tk.constants.FLAT, troughcolor="white", 
                                  activebackground="grey", relief=tk.constants.FLAT, highlightthickness=0, sliderlength=15)
        self.timeSlider.grid(row="1", column="2", sticky="we")
        self.timeSlider.bind("<Button>", lambda e: self.pauseButtonRelease(e) if not self.mainWindow.characterDetector.playbackLogReader.paused else False)
        self.timeSlider.bind("<Key>", lambda e: self.pauseButtonRelease(e) if not self.mainWindow.characterDetector.playbackLogReader.paused else False)
        self.timeSlider.focus_set()
        #self.timeSlider.bind("<ButtonRelease-1>", lambda e: True if not self.mainWindow.characterDetector.playbackLogReader.paused else self.pauseButtonRelease(e)) 
Example #21
Source File: ttk.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, master=None, **kw):
        """Construct a Ttk Scale with parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus

        WIDGET-SPECIFIC OPTIONS

            command, from, length, orient, to, value, variable
        """
        Widget.__init__(self, master, "ttk::scale", kw) 
Example #22
Source File: cameraConfig.py    From crappy with GNU General Public License v2.0 5 votes vote down vote up
def create_scale(self,setting,pos):
    f = tk.Frame(self.root)
    f.grid(row=pos+2,column=1,sticky=tk.E+tk.W)
    if type(setting.limits[0]) is float:
      step = (setting.limits[1]-setting.limits[0])/1000
    else:
      step = 1 # To go through all possible int values
    tk.Label(f,text=setting.name).pack()
    self.scales[setting.name] = tk.Scale(f,orient='horizontal',
        resolution=step, length=self.scale_length,
        from_=setting.limits[0],to=setting.limits[1])
    self.scales[setting.name].pack()
    self.scales[setting.name].set(setting.value) 
Example #23
Source File: frame_objects.py    From crappy with GNU General Public License v2.0 5 votes vote down vote up
def add_scale(self, **kwargs):
    """
    To add a scrollbar
    """
    widgets_dict = kwargs.pop('widgets_dict', None)
    frame = kwargs.pop('frame', None)
    name = kwargs.pop('name', 'Button')
    boundaries = kwargs.pop("boundaries", (0, 1))

    widgets_dict[name] = tk.Scale(frame,
                                  from_=boundaries[0],
                                  to_=boundaries[1],
                                  orient=tk.HORIZONTAL,
                                  ) 
Example #24
Source File: plot_wingbox.py    From OpenAeroStruct with Apache License 2.0 5 votes vote down vote up
def draw_slider(self):
        # scale to choose iteration to view
        self.w = Tk.Scale(
            self.options_frame,
            from_=0, to=self.num_iters - 1,
            orient=Tk.HORIZONTAL,
            resolution=1,
            font=tkFont.Font(family="Helvetica", size=10),
            command=self.update_graphs,
            length=200)

        if self.curr_pos == self.num_iters - 1 or self.curr_pos == 0 or self.var_ref.get():
            self.curr_pos = self.num_iters - 1
        self.w.set(self.curr_pos)
        self.w.grid(row=0, column=1, padx=5, sticky=Tk.W) 
Example #25
Source File: plot_wing.py    From OpenAeroStruct with Apache License 2.0 5 votes vote down vote up
def draw_slider(self):
        # scale to choose iteration to view
        self.w = Tk.Scale(
            self.options_frame,
            from_=0, to=self.num_iters - 1,
            orient=Tk.HORIZONTAL,
            resolution=1,
            font=tkFont.Font(family="Helvetica", size=10),
            command=self.update_graphs,
            length=200)

        if self.curr_pos == self.num_iters - 1 or self.curr_pos == 0 or self.var_ref.get():
            self.curr_pos = self.num_iters - 1
        self.w.set(self.curr_pos)
        self.w.grid(row=0, column=1, padx=5, sticky=Tk.W) 
Example #26
Source File: widgets_testing.py    From kpk2016 with GNU General Public License v3.0 5 votes vote down vote up
def init_main_window():
    """
    Инициализация главного окна: создание всех необходимых виджетов и их упаковка.
    :return:
    """
    global root, button1, button2, label, text, scale

    root = tkinter.Tk()

    button1 = tkinter.Button(root, text="Button 1", command=button1_command)
    button1.bind("<Button>", print_hello)

    button2 = tkinter.Button(root, text="Button 2")
    button2.bind("<Button>", print_hello)

    variable = tkinter.IntVar(0)
    label = tkinter.Label(root, textvariable=variable)
    scale = tkinter.Scale(root, orient=tkinter.HORIZONTAL, length=300,
                          from_=0, to=100, tickinterval=10, resolution=5, variable=variable)
    text = tkinter.Entry(root, textvariable=variable)

    for obj in button1, button2, label, scale, text:
        obj.pack() 
Example #27
Source File: gui_widgets.py    From SVPV with MIT License 5 votes vote down vote up
def __init__(self, parent):
        tk.LabelFrame.__init__(self, parent)
        self.af_on = tk.IntVar(value=0)
        self.af_on_cb = tk.Checkbutton(self, text="AF Threshold", variable=self.af_on)
        self.af_on_cb.grid(row=0, column=0, padx=3, columnspan=2, sticky=tk.EW)
        self.af_var = tk.DoubleVar()
        self.af_gt_lt = tk.IntVar(value=1)
        self.af_lt_radio_button = tk.Radiobutton(self, text="<", variable=self.af_gt_lt, value=1)
        self.af_lt_radio_button.grid(row=1, column=0, sticky=tk.EW)
        self.af_gt_radio_button = tk.Radiobutton(self, text=">", variable=self.af_gt_lt, value=2)
        self.af_gt_radio_button.grid(row=1, column=1, sticky=tk.EW)

        self.af_scale = tk.Scale(self, variable=self.af_var, from_=float(0), to=float(1), resolution=float(0.01),
                                 orient=tk.HORIZONTAL)
        self.af_scale.grid(row=2, column=0, padx=3, sticky=tk.EW, columnspan=2) 
Example #28
Source File: PID_controller_tuner.py    From crazyflie-lib-python with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, master):
        self.master = master
        self.master.title('PID tuner Crazyflie')

        self.figplot = plt.Figure(figsize=(5, 4), dpi=100)
        self.ax2 = self.figplot.add_subplot(111)
        self.line2 = FigureCanvasTkAgg(self.figplot, self.master)
        self.line2.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)

        self.scale_Kp = tk.Scale(master, label='scale_Kp', from_=0, to=20,
                                 length=600, tickinterval=2, resolution=0.1,
                                 orient=tk.HORIZONTAL)
        self.scale_Ki = tk.Scale(master, label='scale_Ki', from_=0, to=10,
                                 length=600, tickinterval=1, resolution=0.1,
                                 orient=tk.HORIZONTAL)
        self.scale_Kd = tk.Scale(master, label='scale_Kd', from_=0, to=10,
                                 length=600, tickinterval=1, resolution=0.1,
                                 orient=tk.HORIZONTAL)

        self.scale_Kp.pack()
        self.scale_Ki.pack()
        self.scale_Kd.pack()

        self.pos_array_prev = []
        self.sp_array_prev = []
        self.time_array_prev = [] 
Example #29
Source File: legofy_gui.py    From Legofy with MIT License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.chosenFile = None
        self.chosenFilePath = tk.StringVar()

        self.pathField = tk.Entry(self, width=40, textvariable=self.chosenFilePath, state=tk.DISABLED)
        self.pathField.grid(row=0, column=0, padx=10)

        self.selectFile = tk.Button(self, text="Choose file...", command=self.choose_a_file)
        self.selectFile.grid(row=0, column=1)

        self.groupFrame = tk.LabelFrame(self, text="Params", padx=5, pady=5)
        self.groupFrame.grid(row=1, column=0, columnspan=2, )

        self.colorPaletteLabel = tk.Label(self.groupFrame, text = 'Color Palette')
        self.colorPaletteLabel.grid(row=0, column=0 )

        self.colorPalette = ttk.Combobox(self.groupFrame)
        self.colorPalette['values'] = LEGO_PALETTE
        self.colorPalette.current(0)
        self.colorPalette.grid(row=0, column=1)

        self.brickNumberScale = tk.Scale(self.groupFrame, from_=1, to=200, orient=tk.HORIZONTAL, label="Number of bricks (longer edge)", length=250)
        self.brickNumberScale.set(30)
        self.brickNumberScale.grid(row=1, column=0, columnspan=2, )

        self.convertFile = tk.Button(text="Legofy this image!", command=self.convert_file)
        self.convertFile.grid(row=2, column=0, columnspan=2) 
Example #30
Source File: ttk.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, master=None, variable=None, from_=0, to=10, **kw):
        """Construct an horizontal LabeledScale with parent master, a
        variable to be associated with the Ttk Scale widget and its range.
        If variable is not specified, a tkinter.IntVar is created.

        WIDGET-SPECIFIC OPTIONS

            compound: 'top' or 'bottom'
                Specifies how to display the label relative to the scale.
                Defaults to 'top'.
        """
        self._label_top = kw.pop('compound', 'top') == 'top'

        Frame.__init__(self, master, **kw)
        self._variable = variable or tkinter.IntVar(master)
        self._variable.set(from_)
        self._last_valid = from_

        self.label = Label(self)
        self.scale = Scale(self, variable=self._variable, from_=from_, to=to)
        self.scale.bind('<<RangeChanged>>', self._adjust)

        # position scale and label according to the compound option
        scale_side = 'bottom' if self._label_top else 'top'
        label_side = 'top' if scale_side == 'bottom' else 'bottom'
        self.scale.pack(side=scale_side, fill='x')
        tmp = Label(self).pack(side=label_side) # place holder
        self.label.place(anchor='n' if label_side == 'top' else 's')

        # update the label as scale or variable changes
        self.__tracecb = self._variable.trace_variable('w', self._adjust)
        self.bind('<Configure>', self._adjust)
        self.bind('<Map>', self._adjust)