def show_Binary(self): ## input Thresh_Binary if (hasattr(self, 'ThBinary')): #(self.varHigh.get()> self.varLow.get()) self.ThBinary.deiconify() else: self.ThBinary = Tk() self.ThBinary.geometry("350x100+350+350") self.ThBinary.title("Binary") self.scale_L = Scale(self.ThBinary, from_=255, to=0, command=self.onScale_L) self.scale_L.pack(side=LEFT, padx=10) self.varLow = IntVar() self.label1 = Label(self.ThBinary, text="LOW") self.label1.pack(side=LEFT, padx=0) self.scale_H = Scale(self.ThBinary, from_=255, to=0, command=self.onScale_H) self.scale_H.pack(side=LEFT, padx=20) self.varHigh = IntVar() self.label2 = Label(self.ThBinary, text="HIGH") self.label2.pack(side=LEFT, padx=1) binary = Button(self.ThBinary, text="OK", width=5, background="green", command=self.getdata_Binary) binary.pack(side=LEFT)
def __init__(self, parent, subject): print("Controller : __init__") self.subject = subject self.amp = IntVar() self.scale_amp = Scale(parent, variable=self.amp, label="Amplitude", orient="horizontal", length=250, from_=0, to=5, relief="sunken", sliderlength=20, tickinterval=1, command=self.update_amplitude) self.freq = IntVar() self.scale_freq = Scale(parent, variable=self.freq, label="Frequence", orient="horizontal", length=250, from_=0, to=5, relief="sunken", sliderlength=20, tickinterval=1, command=self.update_frequence)
def __init__(self, parent, name="X"): """ Initialisation parent : un oscilloscope name : nom du signal """ Frame.__init__(self) self.configure(bd=1, relief="sunken") self.parent = parent self.name = name self.drawVar = IntVar() self.signal = None self.draw = Checkbutton(self, text="Afficher " + self.name, selectcolor=eval('self.parent.view.color_' + name), variable=self.drawVar, onvalue=1, offvalue=0, command=self.parent.plot_all) self.draw.pack() self.draw.select() self.scale_A = Scale(self, length=100, orient="horizontal", label=name + " Amplitude", showvalue=1, from_=0, to=10, tickinterval=1, command=self.update_signal) self.scale_A.pack(expand="yes", fill="both") self.scale_F = Scale(self, length=100, orient="horizontal", label=name + " Fréquence", showvalue=1, from_=1, to=10, tickinterval=1, command=self.update_signal) self.scale_F.pack(expand="yes", fill="both") self.scale_P = Scale(self, length=100, orient="horizontal", label=name + " Phase", showvalue=1, from_=0, to=10, tickinterval=1, command=self.update_signal) self.scale_P.pack(expand="yes", fill="both") self.bind("<Configure>", self.update_signal)
def __init_motor(self): self.w_lf_motor = LabelFrame(self.window, text=u'Моторы') self.w_scale_motor1 = Scale(self.w_lf_motor, from_=-255, to=255) self.w_scale_motor2 = Scale(self.w_lf_motor, from_=-255, to=255) self.w_lf_motor.place(relx=0, rely=0, relwidth=1, relheight=0.3) self.w_scale_motor1.place(relx=0, rely=0, relwidth=1, relheight=1) self.w_scale_motor2.place(relx=0.5, rely=0, relwidth=1, relheight=1)
def __init__(self, parent=None): """ Initialisation parent : oscilloscope """ Frame.__init__(self) self.configure(bd=1, relief="sunken") self.parent = parent self.scale_time = Scale(self, length=100, orient="horizontal", label="Temps", showvalue=1, from_=1, to=10, tickinterval=1, command=self.update) self.scale_time.pack(expand="yes", fill="both") # choix d'afficher lissajoux ou pas self.check = Checkbutton(self, text="Afficher lissajou", selectcolor=self.parent.lissajoux.color_XY, command=self.parent.plot_all, variable=self.parent.drawXY, onvalue=1, offvalue=0) self.check.pack(side="top", expand="yes", fill="x") self.check.select()
def FDL(k, fName): """Infitie loop function which constantly runs the display given the file name of the sequences and an initial k""" global kInput #Gets the initial de Bruijn Graph fdlNodes, minSeqLen = getFDLNodes(k, fName) #Sets up kInput to the appriate scale (3 to the shortest length - 1 ) to ensure # all sequence reads are always included if not kInput: minSeqLen -= 1 kInput = Scale(root, from_=3, to=minSeqLen, orient=HORIZONTAL, label="K", relief=FLAT) kInput.set(k) #sets the initial k value kInput.pack(side=LEFT, padx=50, pady=10) #generates all lines from the initial graph lines = addLines(fdlNodes) #starts inifinite recursive loop for redraw function move_nodes(fdlNodes, kInput.get(), kInput.get(), lines, root, fName) #starts display root.mainloop()
def __init__(self,parent,bg="white"): self.canvas=Canvas(parent,bg=bg) print("parent",parent.cget("width"),parent.cget("height")) self.magnitude=Scale(parent,length=250,orient="horizontal", label="Magnitude", sliderlength=20, showvalue=0,from_=0,to=5, tickinterval=25)
def addPage(self, name): page = ttk.Frame(self.panelControl) self.panelControl.add(page, text='signal ' + name) visible_checkbox = Checkbutton(page, text="Afficher") magnitude = Scale(page, length=250, orient="horizontal", label="Amplitude", sliderlength=20, showvalue=0, from_=0, to=5, tickinterval=1, name="magnitudeScale") frequency = Scale(page, length=250, orient="horizontal", label="Frequency", sliderlength=20, showvalue=0, from_=0, to=25, tickinterval=5, name="frequencyScale") phase = Scale(page, length=250, orient="horizontal", label="Phase", sliderlength=20, showvalue=0, from_=0, to=20, tickinterval=5, name="phaseScale") visible_checkbox.pack(fill="x", pady=6) magnitude.pack(expand=1, fill="both", pady=6) frequency.pack(expand=1, fill="both", pady=6) phase.pack(expand=1, fill="both", pady=6) self.panel_control_page.append({ 'visible': visible_checkbox, 'magnitude': magnitude, 'frequency': frequency, 'phase': phase })
def __init__(self, parent): Frame.__init__(self, parent) self.result = 0 self.master.title("This is a test") self.master.minsize(width=600, height=800) #self.master. self.prompt = Label(self, text="Enter a number:", anchor="w", fg="#984301") self.entry = Entry(self, width=50, highlightcolor="red") self.submit = Button(self, text="Submit", command=self.calculate) self.exit = Button(self, text="Exit", command=parent.destroy, fg="red") self.output = Label(self, text="") self.menu = Menu(self, title="Menu test", bg="black") self.canvas = Canvas(self, cursor="circle", highlightcolor="blue", bg="#019bf0") self.button1 = Button(self, text = "tast antum", bg = "red", fg = "green", command = self.newWindow, \ activebackground = "red", activeforeground = "blue", relief = "sunken", cursor = "dot") self.newFrame = Frame(self, bg="green", highlightcolor="blue") self.button2 = Button(self.newFrame, text="This is a tast") self.button2.grid() self.scale = Scale(self, from_=50, to_=60, orient="horizontal", digits=3, resolution=0.25, highlightcolor="red", command=self.calculate) self.scale.pack() self.open_file_button = Button(self, text="Open File", command=self.openFile) self.prompt.pack(side="top", fill="x") self.entry.pack(side="top", fill="x") self.output.pack(side="top", fill="x", expand=True) self.submit.pack(side="right") self.exit.pack(side="left") self.button1.pack(fill="x") self.newFrame.pack(side="bottom", fill="x", expand=True) self.button2.grid() self.canvas.pack() self.open_file_button.pack() #self.slider.pack() #self.tk = Tkinter.Tk() #self.tk.withdrow() #self.file_path = Tkinter.filedialog.askopenfilename() #print("test") self.entry.insert(string="3", index=0)
def __init__(self, master, name, from_, to, tickinterval, length, orient, command): self.s = 3*[None] axes = ['X','Y','Z'] for i in range(3): self.s[i] = Scale(master, label=name+' '+axes[i], from_=from_[i], to=to[i], tickinterval=tickinterval[i], orient=orient[i], length=length[i], command=command) self.s[i].pack() separator = Frame(height=2, bd=1, relief=tk.SUNKEN) separator.pack(fill=tk.X, padx=5, pady=5)
def __init__(self, parent, name="X"): """ Initialisation parent : un oscilloscope name : nom du signal """ Frame.__init__(self) self.configure(bd=1, relief="sunken") self.parent = parent self.name = name self.scale_A = Scale(self, length=100, orient="horizontal", label=name + " Amplitude", showvalue=1, from_=0, to=10, tickinterval=1, command=self.update_signal) self.scale_F = Scale(self, length=100, orient="horizontal", label=name + " Fréquence", showvalue=1, from_=0, to=10, tickinterval=1, command=self.update_signal) self.scale_P = Scale(self, length=100, orient="horizontal", label=name + " Phase", showvalue=1, from_=0, to=5, tickinterval=1, command=self.update_signal) self.scale_F.pack(expand="yes", fill="both") self.scale_A.pack(expand="yes", fill="both") self.scale_P.pack(expand="yes", fill="both")
def __init__(self, a, frame, view): self.view = view amin = np.amin(a) amax = np.amax(a) # Image min and max values self.min_var = IntVar(value=amin) self.max_var = IntVar(value=amax) self.min_label = Label(frame, text="Min.") self.max_label = Label(frame, text="Max.") self.min_entry = Entry(frame, textvariable=self.min_var) self.max_entry = Entry(frame, textvariable=self.max_var) self.min_entry.bind( "<Return>", lambda event: self.min_entry_change( self.min_scale, self.min_var.get())) self.max_entry.bind( "<Return>", lambda event: self.max_entry_change( self.max_scale, self.max_var.get())) self.min_scale = Scale(frame, orient=HORIZONTAL, from_=amin, to=amax - 1, length=150, command=self.min_change) self.max_scale = Scale(frame, orient=HORIZONTAL, from_=amin + 1, to=amax, length=150, command=self.max_change) self.min_scale.set(amin) self.max_scale.set(amax) self.min_label.grid(row=0, column=0, sticky='w') self.max_label.grid(row=1, column=0, sticky='w') self.min_entry.grid(row=0, column=1, ipady=2) self.max_entry.grid(row=1, column=1, ipady=2) self.min_scale.grid(row=0, column=2, sticky='e', padx=10) self.max_scale.grid(row=1, column=2, sticky='e', padx=10)
def __init__(self, parent=None): Frame.__init__(self, parent) self.pack(side=BOTTOM, anchor=S, fill=X) self.scale = Scale(self, from_=0, to=1, sliderlength=10, showvalue=YES, tickinterval=10, orient='horizontal') self.scale.pack(fill=X)
def __init__(self, parent, bg="white"): self.canvas = Canvas(parent, bg=bg) self.canvas.bind("<Configure>", self.resize) self.width = int(self.canvas.cget("width")) self.height = int(self.canvas.cget("height")) print("parent", parent.cget("width"), parent.cget("height")) self.magnitude = Scale(parent, length=250, orient="horizontal", label="Magnitude", sliderlength=20, showvalue=0, from_=0, to=10, tickinterval=1, relief="sunken") self.frequency = Scale(parent, length=250, orient="horizontal", label="Frequency", sliderlength=20, showvalue=0, from_=0, to=10, tickinterval=1, relief="sunken") self.phase = Scale(parent, length=250, orient="horizontal", label="Phase", sliderlength=20, showvalue=0, from_=0, to=10, tickinterval=1, relief="sunken")
def createOptionsFrame(self,parent): self.frame = Frame(parent) self.magnitudeY=Scale(self.frame,length=250,orient="horizontal", label="Y Magnitude", sliderlength=20, showvalue=0,from_=0,to=4, tickinterval=1) self.frequencyY=Scale(self.frame,length=250,orient="horizontal", label="Y Frequence", sliderlength=20, showvalue=0,from_=0,to=32, tickinterval=6) self.phaseY=Scale(self.frame,length=250,orient="horizontal", label="Y Phase", sliderlength=20, showvalue=0,from_=-180,to=180, tickinterval=90) self.magnitudeX=Scale(self.frame,length=250,orient="horizontal", label="X Magnitude", sliderlength=20, showvalue=0,from_=0,to=4, tickinterval=1) self.frequencyX=Scale(self.frame,length=250,orient="horizontal", label="X Frequence", sliderlength=20, showvalue=0,from_=0,to=32, tickinterval=6) self.phaseX=Scale(self.frame,length=250,orient="horizontal", label="X Phase", sliderlength=20, showvalue=0,from_=-180,to=180, tickinterval=90)
def initUI(self): self.parent.title("Scale") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) scale = Scale(self, from_=0, to=100, command=self.onScale) scale.pack(side=LEFT, padx=15) self.var = IntVar() self.label = Label(self, text=0, textvariable=self.var) self.label.pack(side=LEFT)
def __init__(self, parent=None): """ Initialisation parent : oscilloscope """ Frame.__init__(self) self.configure(bd=1, relief="sunken") self.parent = parent self.scale_time = Scale(self, length=100, orient="horizontal", label="Temps", showvalue=1, from_=1, to=10, tickinterval=1, command=self.update) self.scale_time.pack(expand="yes", fill="both")
def draw_game_info_grid(self): ''' Draw control and inform part of game to right side of the window. ''' self.info = Canvas(self.root, height=self.h - self.gridh, width=self.w - self.gridw) self.info.pack(side="left") label_stones = Label(self.info, text="Current stones:", font=("Helvetica", 10)) label_stones.grid(row=1, column=0) label_max_time = Label(self.info, text="Max time:", font=("Helvetica", 10)) label_max_time.grid(row=2, column=0) label_scale = Label(self.info, text='Game speed [ms]:', font=("Helvetica", 10), foreground='black') label_scale.grid(row=5, column=0) helv36 = font.Font(family="helvetica", size=16, weight='bold') self.scale_var = IntVar() scale = Scale(self.info, variable=self.scale_var, command=self.sleep_time_change_handler, from_=0, to=1000, resolution=10, width="15", orient=HORIZONTAL, length="225") scale.set(200) scale.grid(row=5, column=1, columnspan=3) self.button = Button(self.info, text="Play", width="20", height="2", command=self.play_button_click_handler) self.button['font'] = helv36 self.button.grid(row=6, column=0, columnspan=4) # labels for num stones, max time of move, etc self.label_player_stones = [-1, -1] self.label_player_max_time = [-1, -1] self.labels_inform = [-1, -1] self.labels_player_name = [-1, -1] self.option_menus = [-1, -1] self.option_menus_vars = [-1, -1] for i in range(2): self.label_player_stones[i] = Label(self.info, text='2', font=("Helvetica", 10), foreground=self.colors[i]) self.label_player_stones[i].grid(row=1, column=2 * (i + 1) - 1, columnspan=2) self.label_player_max_time[i] = Label(self.info, text="%.2f [ms]" % 0.0, font=("Helvetica", 10), foreground=self.colors[i]) self.label_player_max_time[i].grid(row=2, column=2 * (i + 1) - 1, columnspan=2) self.labels_inform[i] = Label(self.info, text='', font=("Helvetica", 10), foreground='black') self.labels_inform[i].grid(row=i + 3, column=0, columnspan=4) self.labels_player_name[i] = Label(self.info, text="Player%d:" % (i), font=("Helvetica", 12), foreground=self.colors[i]) self.labels_player_name[i].grid(row=0, column=2 * i) self.option_menus_vars[i] = StringVar(self.root) self.option_menus_vars[i].set(self.interractivePlayerName) self.option_menus[i] = OptionMenu(self.info, self.option_menus_vars[i], *self.possiblePlayers) self.option_menus[i].grid(row=0, column=2 * i + 1)
def create_scale(self, region): """ Create scale for this parameter""" if self._is_int: resolution = 1 else: resolution = 0.001 frame = Frame(region) label = Label(frame, text=self._label) label.pack() scale = Scale(frame, from_=self._top, to=self._bottom, command=self.update_value, resolution=resolution) scale.set(self._value) scale.pack() frame.pack(side=LEFT)
def create_controls(self): canvas = self.area.get_canvas() start = Button(self, text="Start", command=self.start) scale = Scale(self, length=250, orient="horizontal", label='Rayon :', troughcolor='dark grey', sliderlength=20, showvalue=0, from_=0, to=100, tickinterval=25, command=self.update_circle) scale.set(50) canvas.create_window(50, 200, window=start) canvas.create_window(250, 200, window=scale) return start, scale
def gui(self): from Tkinter import Tk, Scale, HORIZONTAL root = Tk() x = Scale(root, from_=0, to=self.HUMERUS + self.ULNA + 2, resolution=0.1, orient = HORIZONTAL, length = 400, command=lambda i: self.dump_target_position( float(i), y.get(), z.get(), g.get(), wa.get(), wr.get()) ) x.pack() x.set(8) y = Scale(root, from_=0, to=self.HUMERUS + self.ULNA + 2, resolution=0.1, orient = HORIZONTAL, length = 400, command=lambda i: self.dump_target_position( x.get(), float(i), z.get(), g.get(), wa.get(), wr.get()) ) y.pack() y.set(6) z = Scale(root, from_=0, to=175, orient = HORIZONTAL, length = 400, command=lambda i: self.dump_target_position( x.get(), y.get(), float(i), g.get(), wa.get(), wr.get()) ) z.pack() z.set(90) g = Scale(root, from_=0, to=175, orient = HORIZONTAL, length = 400, command=lambda i: self.dump_target_position( x.get(), y.get(), z.get(), float(i), wa.get(), wr.get()) ) g.pack() g.set(90) wa = Scale(root, from_=-85, to=85, orient = HORIZONTAL, length = 400, command=lambda i: self.dump_target_position( x.get(), y.get(), z.get(), g.get(), float(i), wr.get()) ) wa.pack() wa.set(0) wr = Scale(root, from_=0, to=175, orient = HORIZONTAL, length = 400, command=lambda i: self.dump_target_position( x.get(), y.get(), z.get(), g.get(), wa.get(), float(i)) ) wr.pack() wr.set(90) root.mainloop()
def __init__(self, master): super(GUI, self).__init__(master) row1, row2, row3, row4 = self.set_rows(4) desc = Label(row1, text="Unify Walk Lengths by mean-Binning the Time Series") desc.pack(fill=tk.X, ipadx=10, ipady=10, side=tk.TOP) dirbutton = Button(row1, text="Select Folder", command=self.define_dir) dirbutton.pack(side=tk.LEFT, expand=True) o = Label(row1, text="or") o.pack(side=tk.LEFT, padx=20, expand=True) filebutton = Button(row1, text="Select Specific File", command=self.define_file) filebutton.pack(side=tk.LEFT, expand=True) self.show_chosen = Label(row2, textvariable=self.chosen, background='white') self.show_chosen.pack(fill=tk.X, side=tk.LEFT, pady=10, ipady=5, ipadx=5, expand=True) nb = Label(row3, text="Number of Bins:", pady=10) nb.pack(side=tk.LEFT) scale = Scale(row3, from_=0, to=150, orient=tk.HORIZONTAL) scale.set(100) scale.pack(side=tk.LEFT, fill=tk.X, expand=True) self.scale = scale row4.pack(fill=tk.NONE) self.go_button = Button(row4, text="GO") self.go_button.pack(side=tk.LEFT, padx=10) self.close_button = Button(row4, text="Close", command=master.destroy) self.close_button.pack(side=tk.RIGHT, padx=10)
def openCmdWindow(self): """ open the cmd window and initial all the button and text """ panel = Toplevel(self.root) panel.wm_title("Command Panel") # create text input entry text0 = tki.Label( panel, text= 'This Controller map keyboard inputs to Tello control commands\n' 'Adjust the trackbar to reset distance and degree parameter', font='Helvetica 10 bold') text0.pack(side='top') text1 = tki.Label( panel, text='W - Move Tello Up\t\t\tArrow Up - Move Tello Forward\n' 'S - Move Tello Down\t\t\tArrow Down - Move Tello Backward\n' 'A - Rotate Tello Counter-Clockwise\tArrow Left - Move Tello Left\n' 'D - Rotate Tello Clockwise\t\tArrow Right - Move Tello Right', justify="left") text1.pack(side="top") self.btn_landing = tki.Button(panel, text="Land", relief="raised", command=self.telloLanding) self.btn_landing.pack(side="bottom", fill="both", expand="yes", padx=10, pady=5) self.btn_takeoff = tki.Button(panel, text="Takeoff", relief="raised", command=self.telloTakeOff) self.btn_takeoff.pack(side="bottom", fill="both", expand="yes", padx=10, pady=5) # binding arrow keys to drone control self.tmp_f = tki.Frame(panel, width=100, height=2) self.tmp_f.bind('<KeyPress-w>', self.on_keypress_w) self.tmp_f.bind('<KeyPress-s>', self.on_keypress_s) self.tmp_f.bind('<KeyPress-a>', self.on_keypress_a) self.tmp_f.bind('<KeyPress-d>', self.on_keypress_d) self.tmp_f.bind('<KeyPress-Up>', self.on_keypress_up) self.tmp_f.bind('<KeyPress-Down>', self.on_keypress_down) self.tmp_f.bind('<KeyPress-Left>', self.on_keypress_left) self.tmp_f.bind('<KeyPress-Right>', self.on_keypress_right) self.tmp_f.pack(side="bottom") self.tmp_f.focus_set() self.btn_landing = tki.Button(panel, text="Flip", relief="raised", command=self.openFlipWindow) self.btn_landing.pack(side="bottom", fill="both", expand="yes", padx=10, pady=5) self.distance_bar = Scale(panel, from_=0.02, to=5, tickinterval=0.01, digits=3, label='Distance(m)', resolution=0.01) self.distance_bar.set(0.2) self.distance_bar.pack(side="left") self.btn_distance = tki.Button( panel, text="Reset Distance", relief="raised", command=self.updateDistancebar, ) self.btn_distance.pack(side="left", fill="both", expand="yes", padx=10, pady=5) self.degree_bar = Scale(panel, from_=1, to=360, tickinterval=10, label='Degree') self.degree_bar.set(30) self.degree_bar.pack(side="right") self.btn_distance = tki.Button( panel, text="Reset Degreejustin bieber love yourself", relief="raised", command=self.updateDegreebar) self.btn_distance.pack(side="right", fill="both", expand="yes", padx=10, pady=5)
def __init__(self, parent, model_x, model_y, bg="white"): self.canvas = Canvas(parent, bg=bg) self.model_x = model_x self.model_y = model_y print("parent", parent.cget("width"), parent.cget("height")) self.showX = True self.showY = True self.frame = Frame(parent) # Signal X self.magnitude_x = Scale(self.frame, length=250, orient="horizontal", name="m_x", label="Magnitude X", sliderlength=20, showvalue=0, from_=0, to=5, tickinterval=25) self.frequency_x = Scale(self.frame, length=250, orient="horizontal", name="f_x", label="Frequency X", sliderlength=20, showvalue=0, from_=0, to=5, tickinterval=25) self.phase_x = Scale(self.frame, length=250, orient="horizontal", name="p_x", label="Phase X", sliderlength=20, showvalue=0, from_=0, to=5, tickinterval=25) # Signal Y self.magnitude_y = Scale(self.frame, length=250, orient="horizontal", name="m_y", label="Magnitude Y", sliderlength=20, showvalue=0, from_=0, to=5, tickinterval=25) self.frequency_y = Scale(self.frame, length=250, orient="horizontal", name="f_y", label="Frequency Y", sliderlength=20, showvalue=0, from_=0, to=5, tickinterval=25) self.phase_y = Scale(self.frame, length=250, orient="horizontal", name="p_y", label="Phase Y", sliderlength=20, showvalue=0, from_=0, to=5, tickinterval=25) self.frame2 = Frame(parent, bg="black") self.varX = IntVar() self.varY = IntVar() self.varXY = IntVar() self.lbl = Label(self.frame2, text="Courbes", fg="black") # Boutons de sélection (X, Y ou X-Y) self.caseX = Checkbutton(self.frame2, text="X", variable=self.varX, command=self.getX) self.caseY = Checkbutton(self.frame2, text="Y", variable=self.varY, command=self.getY) self.caseXY = Checkbutton(self.frame2, text="XY", variable=self.varXY, command=self.getXY) self.caseXY.select() self.wi = self.canvas.cget("width") self.hi = self.canvas.cget("height") self.stepx = 0 self.stepy = 0 # Step x self.step_x = Entry(parent, name="x") # Step y self.step_y = Entry(parent, name="y")
def __init__(self, title="Visualisation", width=400, height=400, recording=False, recordPattern=None, paused=False, source=None): ''' Constructor. Params: title: string - Title of the visualisation window width: int - Width of the visualisation window height: int - Height of the visualisation window recording: boolean - Start with recording enabled? recordPattern: string - Pattern for recorded images, e.g., cylinders%05g.png paused: boolean - Start with playback paused? source:- The data source to read. What is required here varies by visualiser. ''' # Visualisation options self.vis_features = [] self.vis_frame = 0 self.vis_frameStep = 1 self.vis_jumping = False self.vis_recording = recording self.vis_recordPattern = recordPattern self.vis_paused = paused self.vis_source = source # VTK structures self.vtk_cells = vtkCellArray() self.vtk_renderer = vtkRenderer() # Tk structures self.tk_root = Tk() self.tk_root.title(title) self.tk_root.grid_rowconfigure(0, weight=1) self.tk_root.grid_columnconfigure(0, weight=3) self.tk_root.bind('<Destroy>', self.destroyed) if not self.vis_paused: self.tk_root.after(100, self.animate) self.tk_renderWidget = vtkTkRenderWidget(self.tk_root, width=width, height=height) self.tk_renderWidget.grid(row=0, column=0, sticky=N+S+E+W) self.tk_renderWidget.GetRenderWindow().AddRenderer(self.vtk_renderer) self.tk_featureFrame = Frame(self.tk_root) self.tk_featureFrame.grid(row=0, column=1, rowspan=2) Label(self.tk_featureFrame, text='Features:').grid(row=0, column=0) self.tk_controlFrame = Frame(self.tk_root) self.tk_controlFrame.grid(row=1, column=0) self.tk_quit = Button(self.tk_controlFrame, text="Quit", command=self.shutdown) self.tk_quit.grid(row=0, column=0, columnspan=2) def pause(): if self.vis_paused: self.tk_pause.config(text='Pause') self.tk_root.after(100, self.animate) else: self.tk_pause.config(text='Resume') self.vis_paused ^= True self.tk_pause = Button(self.tk_controlFrame, text="Pause", command=pause) self.tk_pause.grid(row=0, column=2, columnspan=2) if self.vis_recordPattern is not None: def record(): if self.vis_recording: self.tk_record.config(text='Start Recording') else: self.tk_record.config(text='Stop Recording') self.vis_recording ^= True self.tk_record = Button(self.tk_controlFrame, text="Start Recording", command=record) self.tk_record.grid(row=0, column=4, columnspan=2) if self.vis_recording: self.tk_record.config(text="Stop Recording") def make_seek_button(label, column, frame): def jump(): self.jumpTo(frame) b = Button(self.tk_controlFrame, text=label, command=jump) b.grid(row=1, column=column, sticky=W+E) return b self.tk_seek_start = make_seek_button("|<", 0, 0) self.tk_seek_back10 = make_seek_button("<<", 1, lambda: self.vis_frame - 10) self.tk_seek_back1 = make_seek_button("<", 2, lambda: self.vis_frame - 1) self.tk_seek_forward1 = make_seek_button(">", 3, lambda: self.vis_frame + 1) self.tk_seek_forward10 = make_seek_button(">>", 4, lambda: self.vis_frame + 10) self.tk_seek_end = make_seek_button(">|", 5, self.getMaxFrameNumber) Label(self.tk_controlFrame, text='Frame').grid(row=2, column=0, sticky=W+E) def changeFrame(frame): if not self.vis_jumping: self.vis_jumping = True self.jumpTo(self.tk_frame.get()) self.vis_jumping = False self.tk_frame = Scale(self.tk_controlFrame, command=changeFrame, from_=0, to=0, orient=HORIZONTAL) self.tk_frame.grid(row=2, column=1, columnspan=2, sticky=W+E) Label(self.tk_controlFrame, text='Step').grid(row=2, column=3, sticky=W+E) def changeFrameStep(step): self.vis_frameStep = int(step) self.tk_frameStep = Scale(self.tk_controlFrame, command=changeFrameStep, from_=1, to=1, orient=HORIZONTAL) self.tk_frameStep.grid(row=2, column=4, columnspan=2, sticky=W+E) self.setupGrid()
def gui(): from Tkinter import Tk, Label, Entry, Button, Scale, Checkbutton, W, HORIZONTAL, Frame, StringVar, IntVar, DoubleVar, Radiobutton, BooleanVar, E global root root = Tk() root.wm_title("Compute R_complete") line = 0 global insFile, hklFile, nHKL, nParams, nHKLLabel, fracFree, status, nParamsLabel, nCPU, rCompleteLabel, cycles, lsType, cleanup, nFree, nRunsLabel, mergeCheck, compileMap insFile = StringVar() hklFile = StringVar() nHKL = IntVar() nParams = IntVar() nFree = IntVar() fracFree = DoubleVar() fracFree.set(5.0) nCPU = IntVar() nCPU.set(maxCPU) cycles = IntVar() cycles.set(10) lsType = IntVar() lsType.set(1) cleanup = BooleanVar() cleanup.set(True) mergeCheck = BooleanVar() mergeCheck.set(True) compileMap = BooleanVar() compileMap.set(True) Label(root, text='Instruction File:').grid(row=line, column=0, sticky=E) Entry(root, textvariable=insFile).grid(row=line, column=1) Button(root, text='Browse', command=browseINS).grid(row=line, column=2) line += 1 Label(root, text='Reflection File:').grid(row=line, column=0, sticky=E) Entry(root, textvariable=hklFile).grid(row=line, column=1) Button(root, text='Browse', command=browseHKL).grid(row=line, column=2) line += 1 Checkbutton(root, var=mergeCheck, text='Merge Reflections').grid(row=line, column=1, sticky=W) line += 1 Button(root, text='Load', command=load).grid(row=line, columnspan=3) line += 1 Frame(root, height=20).grid(row=line) line += 1 Label(root, text='# of reflections:').grid(row=line, sticky=E) nHKLLabel = Label(root, text='???') nHKLLabel.grid(row=line, column=1, sticky=W) line += 1 Label(root, text='# of atoms:').grid(row=line, sticky=E) nParamsLabel = Label(root, text='???') nParamsLabel.grid(row=line, column=1, sticky=W) line += 1 Frame(root, height=20).grid(row=line) line += 1 Label(root, text='Select Parameters').grid(row=line, column=1) line += 1 Frame(root, height=20).grid(row=line) line += 1 Label(root, text='# of free reflections:').grid(row=line, sticky=E) nFreeEntry = Entry(root, width=5, textvariable=nFree) nFreeEntry.grid(row=line, column=1, sticky=W) nFreeEntry.bind('<Return>', setScale) nRunsLabel = Label(root, text='# runs') nRunsLabel.grid(row=line, column=2) line += 1 Label(root, text='% of free reflections:').grid(row=line, column=0, sticky=E) w = Scale(root, from_=0.1, to=10.0, resolution=0.1, orient=HORIZONTAL, length=200, var=fracFree, command=percentScale) w.grid(row=line, column=1, columnspan=2, sticky=W) line += 1 Label(root, text='stable <-------------------------------> fast').grid( row=line, column=1, columnspan=2, sticky=W) line += 1 Frame(root, height=10).grid(row=line) line += 1 Label(root, text='Refinement cycles:').grid(row=line, column=0, sticky=E) ls = Scale(root, from_=0, to=50, resolution=1, orient=HORIZONTAL, length=200, var=cycles) ls.grid(row=line, column=1, columnspan=2, sticky=W) line += 1 Label(root, text='fast <--------------------> less model bias').grid( row=line, column=1, columnspan=2, sticky=W) line += 1 Frame(root, height=10).grid(row=line) line += 1 Label(root, text='# of CPUs:').grid(row=line, column=0, sticky=E) ww = Scale(root, from_=1, to=maxCPU, orient=HORIZONTAL, length=200, var=nCPU) ww.grid(row=line, column=1, columnspan=2, sticky=W) line += 1 Label(root, text='Refinement Type:').grid(row=line, column=0, sticky=E) Radiobutton(root, text='CGLS', var=lsType, value=1).grid(row=line, column=1, sticky=W) Radiobutton(root, text='L.S.', var=lsType, value=2).grid(row=line, column=2, sticky=W) line += 1 Frame(root, height=10).grid(row=line) line += 1 Label(root, text='Compile map:').grid(row=line, column=0, sticky=E) Checkbutton(root, var=compileMap).grid(row=line, column=1, sticky=W) line += 1 Label(root, text='Cleanup:').grid(row=line, column=0, sticky=E) Checkbutton(root, var=cleanup).grid(row=line, column=1, sticky=W) line += 1 Button(root, text='RUN', command=run, width=25).grid(row=line, columnspan=3) line += 1 Frame(root, height=20).grid(row=line) line += 1 Label(root, text='R_complete:').grid(row=line, column=0, sticky=E) rCompleteLabel = Label(root, text='???') rCompleteLabel.grid(row=line, column=1, sticky=W) line += 1 Frame(root, height=20).grid(row=line) line += 1 Label(root, text='Status:').grid(row=line, column=0, sticky=E) status = Label(root, text='Idle... Please load files.') status.grid(row=line, column=1, columnspan=2, sticky=W) global IDLE IDLE = True root.mainloop()
entry_InvariantM2 = Entry(OptionsLep, textvariable=InvariantM2_val, validate='key', vcmd=vcmd, width=3) LabelInvMass = Label(OptionsLep, bg="lavender") LabelInvMass2 = Label( OptionsLep, text="Invariant mass of pair 2:", bg="lavender") #Some labels to idicate what the entries are #slider for min transverse mass slider_LepTMass = Scale(OptionsLep, from_=0, to=200, orient=HORIZONTAL, length=170, width=10, variable=LepTmass_val, bg="lavender", label="Minimum transverse mass") #slider for max transverse mass slider_maxLepTMass = Scale(OptionsLep, from_=0, to=200, orient=HORIZONTAL, length=170, width=10, variable=LepTmassMax_val, bg="lavender", label="Maximum transverse mass")
def sunfounder_client(ip, key): #!/usr/bin/env python # -*- coding: utf-8 -*- from Tkinter import Tk, Button, Label, Scale, HORIZONTAL print "Connecting to IP", ip ctrl_cmd = ['forward', 'backward', 'left', 'right', 'stop', 'read cpu_temp', 'home', 'distance', 'x+', 'x-', 'y+', 'y-', 'xy_home'] top = Tk() # Create a top window top.title('Sunfounder Raspberry Pi Smart Video Car') HOST = ip # Server(Raspberry Pi) IP address PORT = 21567 BUFSIZ = 1024 # buffer size ADDR = (HOST, PORT) tcpCliSock = socket(AF_INET, SOCK_STREAM) # Create a socket tcpCliSock.connect(ADDR) # Connect with the server # ============================================================================= # The function is to send the command forward to the server, so as to make the # car move forward. # ============================================================================= def forward_fun(event): print "\nUser command = forward" print "Encrypted command = ",crypto.AES_encrypt('forward',key)[2] tcpCliSock.send(str(crypto.AES_encrypt('forward',key))) def backward_fun(event): print '\nUser command = backward' print "Encrypted command = ",crypto.AES_encrypt('backward',key)[2] tcpCliSock.send(str(crypto.AES_encrypt('backward',key))) def left_fun(event): print '\nUser command = left' print "Encrypted command = ",crypto.AES_encrypt('left',key)[2] tcpCliSock.send(str(crypto.AES_encrypt('left',key))) def right_fun(event): print '\nUser command = right' print "Encrypted command = ",crypto.AES_encrypt('right',key)[2] tcpCliSock.send(str(crypto.AES_encrypt('right',key))) def stop_fun(event): print '\nUser command = stop' print "Encrypted command = ",crypto.AES_encrypt('stop',key)[2] tcpCliSock.send(str(crypto.AES_encrypt('stop',key))) def home_fun(event): print '\nUser command = home' print "Encrypted command = ",crypto.AES_encrypt('home',key)[2] tcpCliSock.send(str(crypto.AES_encrypt('home',key))) def x_increase(event): print '\nUser command = x+' print "Encrypted command = ",crypto.AES_encrypt('x+',key)[2] tcpCliSock.send(str(crypto.AES_encrypt('x+',key))) def x_decrease(event): print '\nUser command = x-' print "Encrypted command = ",crypto.AES_encrypt('x-',key)[2] tcpCliSock.send(str(crypto.AES_encrypt('x-',key))) def y_increase(event): print '\nUser command = y+' print "Encrypted command = ",crypto.AES_encrypt('y+',key)[2] tcpCliSock.send(str(crypto.AES_encrypt('y+',key))) def y_decrease(event): print '\nUser command = y-' print "Encrypted command = ",crypto.AES_encrypt('y-',key)[2] tcpCliSock.send(str(crypto.AES_encrypt('y-',key))) def xy_home(event): print '\nUser command = xy_home' print "Encrypted command = ",crypto.AES_encrypt('xy_home',key)[2] tcpCliSock.send(str(crypto.AES_encrypt('xy_home',key))) # ============================================================================= # Exit the GUI program and close the network connection between the client # and server. # ============================================================================= def quit_fun(event): print "\nShutting down program..." top.quit() tcpCliSock.send(str(crypto.AES_encrypt('stop',key))) tcpCliSock.close() # ============================================================================= # Create buttons # ============================================================================= Btn0 = Button(top, width=5, text='Forward') Btn1 = Button(top, width=5, text='Backward') Btn2 = Button(top, width=5, text='Left') Btn3 = Button(top, width=5, text='Right') Btn4 = Button(top, width=5, text='Quit') Btn5 = Button(top, width=5, height=2, text='Home') # ============================================================================= # Buttons layout # ============================================================================= Btn0.grid(row=0,column=1) Btn1.grid(row=2,column=1) Btn2.grid(row=1,column=0) Btn3.grid(row=1,column=2) Btn4.grid(row=3,column=2) Btn5.grid(row=1,column=1) # ============================================================================= # Bind the buttons with the corresponding callback function. # ============================================================================= Btn0.bind('<ButtonPress-1>', forward_fun) # When button0 is pressed down, call the function forward_fun(). Btn1.bind('<ButtonPress-1>', backward_fun) Btn2.bind('<ButtonPress-1>', left_fun) Btn3.bind('<ButtonPress-1>', right_fun) Btn0.bind('<ButtonRelease-1>', stop_fun) # When button0 is released, call the function stop_fun(). Btn1.bind('<ButtonRelease-1>', stop_fun) Btn2.bind('<ButtonRelease-1>', stop_fun) Btn3.bind('<ButtonRelease-1>', stop_fun) Btn4.bind('<ButtonRelease-1>', quit_fun) Btn5.bind('<ButtonRelease-1>', home_fun) # ============================================================================= # Create buttons # ============================================================================= Btn07 = Button(top, width=5, text='X+', bg='red') Btn08 = Button(top, width=5, text='X-', bg='red') Btn09 = Button(top, width=5, text='Y-', bg='red') Btn10 = Button(top, width=5, text='Y+', bg='red') Btn11 = Button(top, width=5, height=2, text='HOME', bg='red') # ============================================================================= # Buttons layout # ============================================================================= Btn07.grid(row=1,column=5) Btn08.grid(row=1,column=3) Btn09.grid(row=2,column=4) Btn10.grid(row=0,column=4) Btn11.grid(row=1,column=4) # ============================================================================= # Bind button events # ============================================================================= Btn07.bind('<ButtonPress-1>', x_increase) Btn08.bind('<ButtonPress-1>', x_decrease) Btn09.bind('<ButtonPress-1>', y_decrease) Btn10.bind('<ButtonPress-1>', y_increase) Btn11.bind('<ButtonPress-1>', xy_home) #Btn07.bind('<ButtonRelease-1>', home_fun) #Btn08.bind('<ButtonRelease-1>', home_fun) #Btn09.bind('<ButtonRelease-1>', home_fun) #Btn10.bind('<ButtonRelease-1>', home_fun) #Btn11.bind('<ButtonRelease-1>', home_fun) # ============================================================================= # Bind buttons on the keyboard with the corresponding callback function to # control the car remotely with the keyboard. # ============================================================================= top.bind('<KeyPress-a>', left_fun) # Press down key 'A' on the keyboard and the car will turn left. top.bind('<KeyPress-d>', right_fun) top.bind('<KeyPress-s>', backward_fun) top.bind('<KeyPress-w>', forward_fun) top.bind('<KeyPress-h>', home_fun) top.bind('<KeyRelease-a>', home_fun) # Release key 'A' and the car will turn back. top.bind('<KeyRelease-d>', home_fun) top.bind('<KeyRelease-s>', stop_fun) top.bind('<KeyRelease-w>', stop_fun) spd = 50 def changeSpeed(ev=None): tmp = 'speed' global spd spd = speed.get() data = tmp + str(spd) # Change the integers into strings and combine them with the string 'speed'. #print 'sendData = %s' % data print '\nUser command = ', data print "Encrypted command = ",crypto.AES_encrypt(data,key)[2] tcpCliSock.send(str(crypto.AES_encrypt(data,key))) # Send the speed data to the server(Raspberry Pi) label = Label(top, text='Speed:', fg='red') # Create a label label.grid(row=6, column=0) # Label layout speed = Scale(top, from_=0, to=100, orient=HORIZONTAL, command=changeSpeed) # Create a scale speed.set(50) speed.grid(row=6, column=1) def main(): top.mainloop() if __name__ == '__main__': main()
from Tkinter import Tk,Scale,IntVar,DoubleVar def update_magnitude(event): global data x=int(event.widget.get()) print(x,type(x)) print(data.get(),data.get()) if __name__ == "__main__" : root = Tk() root.title("Oscilloscope v.1") data=DoubleVar() magnitude=Scale(root,variable=data, length=250,orient="horizontal", label="Magnitude",sliderlength=20, showvalue=0,from_=0,to=5,tickinterval=25) magnitude.pack() magnitude.bind("<B2-Motion>",update_magnitude) root.mainloop()
width = 1000 height = 700 #Physics constants. Initial values reset by sliders SPRING_CONSTANT = 0.01 # Contant for sprint force COULOMB_CONSTANT = 0.01 # Constant for coulomb force WALL_CONSTANT = 0.250 # Static constant used for a wall force to center the nodes TIME_CONSTANT = 1.0 # Time constant for speed of forces DECAY_CONSTANT = 1.0 # Speed of damping both overall force and velocity #Initializes the Tkinter frame and sliders root = Tk() #Adds horizontal sliders at the bottom for FDL constants timeInput = Scale(root, from_=1, to=500, orient=HORIZONTAL, label="Time", relief=FLAT) springInput = Scale(root, from_=1, to=1000, orient=HORIZONTAL, label="Spring", relief=FLAT) coulombInput = Scale(root, from_=1, to=1000, orient=HORIZONTAL, label="Coulomb", relief=FLAT) decayInput = Scale(root,