当前位置: 首页>>代码示例>>Python>>正文


Python Scale.pack方法代码示例

本文整理汇总了Python中Tkinter.Scale.pack方法的典型用法代码示例。如果您正苦于以下问题:Python Scale.pack方法的具体用法?Python Scale.pack怎么用?Python Scale.pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tkinter.Scale的用法示例。


在下文中一共展示了Scale.pack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TimeBase

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import pack [as 别名]
class TimeBase(Frame):
    """controleur pour la base de temps

    scale : controle de la valeur de la base de temps
    """
    def __init__(self, parent=None):
        """ initialisation

        parent : oscilloscope
        """
        Frame.__init__(self)
        self.configure(bd=1, relief="sunken")
        self.parent = parent
        self.scale = Scale(self, length=300, orient="horizontal",
                label="Temps", showvalue=1, from_=1, to=10,
                tickinterval=1, command=self.update_time_base)
        self.scale.pack(expand="yes", fill="both")

    def get_time(self):
        """valeur courante de la base de temps"""
        return self.scale.get()

    def update_time_base(self, event):
        """mise a jour de la base de temps"""
        print("TimeBase.update_time_base()")
        print("Base de temps : ", self.scale.get())
        if not isinstance(self.parent, Tk):
            self.parent.update_time(self.scale.get())
开发者ID:Akanoa,项目名称:CAI2014,代码行数:30,代码来源:timebase.py

示例2: Playbar

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import pack [as 别名]
class Playbar(Frame):
    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)
        # We don't set the initial value of the scale here because
        # that's done by tying it to the global variable "slidert"

# Resetscale: takes a frame count and resets scale parms appropriately
    def resetscale(self, frames):
        temp = floor(log10(frames))
        tickinterval = int(pow(10,temp))
        if(tickinterval<1): tickinterval = 1
        self.scale.config(to=frames, tickinterval=tickinterval)
开发者ID:Rahmatollah,项目名称:VAMP,代码行数:19,代码来源:transport.py

示例3: FDL

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import pack [as 别名]
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()
开发者ID:dgriff03,项目名称:deBruijnFDL,代码行数:23,代码来源:debruijn.py

示例4: Simulator

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import pack [as 别名]
class Simulator(Tk):
    def __init__(self, network):
        Tk.__init__(self)
        self.title("DATK")

        self.network = network
        self.n_steps = network.count_snapshots()
        self.network.restore_snapshot(0)
        self.canvas = Canvas(self, width=800, height=500)
        self.canvas.draw(self.network)
        self.canvas.pack()

        self.slider = Scale(self, from_=0, to=self.n_steps-1, length=300,
            orient=HORIZONTAL, command=self.updateValue)
        self.slider.pack(padx=10, pady=10)
    
    def updateValue(self, val):
        self.network.restore_snapshot(int(float(val)))
        self.canvas.draw(self.network)
    
    def destroy(self):
        self.network.restore_snapshot(-1)
        Tk.destroy(self)
开发者ID:amin10,项目名称:datk,代码行数:25,代码来源:simulator_tk.py

示例5: TimeBase

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import pack [as 别名]
class TimeBase(Frame):
    """
    Base de temps

    scale_time : controle  de la base de temps
    """
    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 get_time(self):
        """
        recuperer la valeur courante de la base de temps
        """
        return self.scale_time.get()

    def update(self, event):
        """mise a jour de la base de temps"""
        print("TimeBase.update_time_base()")
        print("Base de temps : ", self.scale_time.get())
        if not isinstance(self.parent, Tk):
            self.parent.update_time(self.scale_time.get())
开发者ID:holiday2018,项目名称:python_oscilloscope,代码行数:39,代码来源:timebase.py

示例6: send_values

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import pack [as 别名]
def send_values(_):
	vr, vg, vb = r.get(), g.get(), b.get()
	res = "{},{},{}".format(vr, vg*212.0/255.0, vb*164.0/255.0)
	print res
	ser.write(res+'\n')
	ard = ser.readline()
	print ard
	ard = ser.readline()
	print ard

master = Tk()
r = Scale(master, from_=0, to=255, length=250, 
		  orient=HORIZONTAL, label="red",
		  command=send_values)
r.pack()
g = Scale(master, from_=0, to=255, length=250, 
		  orient=HORIZONTAL, label="green",
		  command=send_values)
g.pack()
b = Scale(master, from_=0, to=255, length=250, 
		  orient=HORIZONTAL, label="blue",
		  command=send_values)
b.pack()
master.geometry('{}x{}'.format(300, 200))

print r.get()


mainloop()
开发者ID:ice3,项目名称:sunlight_alarm_clock,代码行数:31,代码来源:calibration.py

示例7: Vibration

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import pack [as 别名]
class Vibration(Frame):
    def __init__(self, parent, name="X", color="red"):
        """
        Description :
          Calcul d'une vibration harmonique du type : e=a*sin(2*pi*f*t+p)
        Proprietes :
          -  un parent (classe Oscilloscope)
          -  controleurs d'amplitude, frequence, phase (classe Scale)
        Methodes :
          - update_vibration(self, event) : callback si modification de controleurs
          - compute(self,a,f,p) : calcul de vibration harmonique
        """
        Frame.__init__(self)
        self.configure(bd=1, relief="sunken")
        self.parent = parent
        self.name = name
        self.scale_A = Scale(self, length=300, orient="horizontal",
                label=name + " Amplitude", showvalue=1, from_=0, to=10,
                tickinterval=1, command=self.update_vibration)

        self.scale_P = Scale(self, length=300, orient="horizontal",
                label=name + " Phase", showvalue=1, from_=0, to=90,
                tickinterval=20, command=self.update_vibration)

        self.scale_F = Scale(self, length=300, orient="horizontal",
                label=name + " Fréquence", showvalue=1, from_=0, to=100,
                tickinterval=10, command=self.update_vibration)

        self.scale_A.pack(expand="yes", fill="both")
        self.scale_P.pack(expand="yes", fill="both")
        self.scale_F.pack(expand="yes", fill="both")

    def update_vibration(self, event):
        """
        mise  a jour de courbe si modifications (amplitude, frequence, phase)
        """
        print("Vibration.update_vibration()")
        print("Amplitude :", self.scale_A.get())
        curve = self.compute(self.scale_A.get(), self.scale_F.get(),self.scale_P.get(), self.parent.get_time())
        if not isinstance(self.parent, Tk):
            self.parent.draw_curve(self.name, curve)

    def compute(self, a=0, f=0, p=0, timeBase=1):
        """
        Calcul de l'elongation en fonction de base de temps, amplitude, frequence, phase
        """
        curve = []
        print("Vibration.compute()")
        if not isinstance(self.parent, Tk):
            print("Base de Temps :", timeBase)
            #t = self.parent.get_time()
            #curve.append((self.scale_A.get() + 10*t, self.scale_A.get() + 10*t))
            #curve.append((self.scale_A.get() + 20*t, self.scale_A.get() + 20*t))
            # calcul des points de la courbe en fct de la base de temps (cf poly)

            for t in range(0, 1001, 5):
                e = a*sin(2*pi*f*t/1000*timeBase-p)
                x = t
                y = e
                curve.append((x,y))
        return curve
开发者ID:Akanoa,项目名称:CAI2014,代码行数:63,代码来源:vibration.py

示例8: App

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import pack [as 别名]
class App(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()

        self.vcmd = self.register(self.validate)

        self.hue_group = Frame(master)
        self.hue_group.pack()
        self.saturation_group = Frame(master)
        self.saturation_group.pack()
        self.value_group = Frame(master)
        self.value_group.pack()
        self.red_group = Frame(master)
        self.red_group.pack()
        self.green_group = Frame(master)
        self.green_group.pack()
        self.blue_group = Frame(master)
        self.blue_group.pack()

        self.hue = StringVar(master, 0)  # range 0 360
        self.hue_max = 360
        self.saturation = StringVar(master, 100)  # range 0 100
        self.saturation_max = 100
        self.value = StringVar(master, 100)  # range 0 100
        self.value_max = 100

        self.color_max = 255
        self.red = StringVar(master, 255)  # range 0 255
        self.green = StringVar(master, 0)  # range 0 255
        self.blue = StringVar(master, 0)  # range 0 255

        self.create_sliders(master)
        self.create_entries(master)

    def create_sliders(self, master=None):
        """Create the Color Sliders."""
        self.hue_scale = Scale(self.hue_group, orient="horizontal",
                               showvalue="false", variable=self.hue)
        self.hue_scale["from"] = 0
        self.hue_scale["to"] = 360
        self.hue_scale.pack(side=LEFT)

        self.saturation_scale = Scale(self.saturation_group,
                                      orient="horizontal",
                                      showvalue="false",
                                      variable=self.saturation)
        self.saturation_scale["from"] = 0
        self.saturation_scale["to"] = 100
        self.saturation_scale.pack(side=LEFT)

        self.value_scale = Scale(self.value_group, orient="horizontal",
                                 showvalue="false", variable=self.value)
        self.value_scale["from"] = 0
        self.value_scale["to"] = 100
        self.value_scale.pack(side=LEFT)

        self.red_scale = Scale(self.red_group, orient="horizontal",
                               showvalue="false", variable=self.red)
        self.red_scale["from"] = 0
        self.red_scale["to"] = 255
        self.red_scale.pack(side=LEFT)

        self.green_scale = Scale(self.green_group, orient="horizontal",
                                 showvalue="false", variable=self.green)
        self.green_scale["from"] = 0
        self.green_scale["to"] = 255
        self.green_scale.pack(side=LEFT)

        self.blue_scale = Scale(self.blue_group, orient="horizontal",
                                showvalue="false", variable=self.blue)
        self.blue_scale["from"] = 0
        self.blue_scale["to"] = 255
        self.blue_scale.pack(side=LEFT)

    def create_entries(self, master=None):
        """Create the Color Entries."""
        # the number of characters wide entry fields are
        entry_width = 3

        # Very little documentation on validation
        # various substitution codes
        # http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/entry-validation.html
        # useful tutorial
        # http://stupidpythonideas.blogspot.com/2013/12/tkinter-validation.html
        # man pages
        # http://www.tcl.tk/man/tcl8.5/TkCmd/entry.htm#M-validate

        self.hue_entry = Entry(self.hue_group, textvariable=self.hue,
                               width=entry_width, validate="all",
                               validatecommand=(self.vcmd, "%P"))
        self.hue_entry.pack(side=LEFT)

        self.saturation_entry = Entry(self.saturation_group,
                                      textvariable=self.saturation,
                                      width=entry_width, validate="all",
                                      validatecommand=(self.vcmd, "%P"))
        self.saturation_entry.pack(side=LEFT)

        self.value_entry = Entry(self.value_group, textvariable=self.value,
#.........这里部分代码省略.........
开发者ID:mroseman95,项目名称:Palette-Creator,代码行数:103,代码来源:color_picker.py

示例9: WindowExample

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import pack [as 别名]
class WindowExample(Frame):

	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)
		#self.entry.insert(string = "blahblah", index = 3)

	def calculate(self, integer):
		integer = float(integer)
		#try:
		#	i = int(self.entry.get())
		#	self.result = "%s*2=%s" % (i, i*2)
		#except ValueError:
		#	self.result = "Please enter numbers only"
		self.entry.delete(0, len(self.entry.get()))
		self.result = "%s*2=%s" % (integer, integer*2)
		self.entry.insert(0, integer)

		self.output.configure(text=self.result)

	def newWindow(self):
		try:
			r2 = Tk()
			r2.mainloop()
		except ValueError:
			return None

	def openFile(self):
		file_in = tkFileDialog.askopenfilename()
		self.output.configure(text = file_in)
开发者ID:gabastil,项目名称:Python_MacBookAir_NLP_Cebuano_Scripts,代码行数:72,代码来源:WindowExample.py

示例10: EktaproGUI

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import pack [as 别名]
class EktaproGUI(Tk):
    """
    Constructs the main program window
    and interfaces with the EktaproController
    and the TimerController to access the slide
    projectors.  
    """

    def __init__(self):
        self.controller = EktaproController()
        self.controller.initDevices()

        Tk.__init__(self)
        self.protocol("WM_DELETE_WINDOW", self.onQuit)
        self.wm_title("EktaproGUI")

        self.bind("<Prior>", self.priorPressed)
        self.bind("<Next>", self.nextPressed)

        self.brightness = 0
        self.slide = 1
        self.timerController = TimerController(self.controller, self)

        self.controlPanel = Frame(self)
        self.manualPanel = Frame(self)

        self.projektorList = Listbox(self, selectmode=SINGLE)

        for i in range(len(self.controller.devices)):
            self.projektorList.insert(END, "[" + str(i) + "] " + str(self.controller.devices[i]))

        if self.projektorList.size >= 1:
            self.projektorList.selection_set(0)

        self.projektorList.bind("<ButtonRelease>", self.projektorSelectionChanged)
        self.projektorList.config(width=50)

        self.initButton = Button(self.controlPanel, text="init", command=self.initButtonPressed)
        self.nextButton = Button(self.controlPanel, text="next slide", command=self.nextSlidePressed)
        self.nextButton.config(state=DISABLED)
        self.prevButton = Button(self.controlPanel, text="previous slide", command=self.prevSlidePressed)
        self.prevButton.config(state=DISABLED)

        self.startButton = Button(self.controlPanel, text="start timer", command=self.startTimer)
        self.startButton.config(state=DISABLED)
        self.pauseButton = Button(self.controlPanel, text="pause", command=self.pauseTimer)
        self.stopButton = Button(self.controlPanel, text="stop", command=self.stopTimer)
        self.stopButton.config(state=DISABLED)
        self.timerLabel = Label(self.controlPanel, text="delay:")
        self.timerInput = Entry(self.controlPanel, width=3)
        self.timerInput.insert(0, "5")
        self.timerInput.config(state=DISABLED)
        self.timerInput.bind("<KeyPress-Return>", self.inputValuesChanged)
        self.timerInput.bind("<ButtonRelease>", self.updateGUI)

        self.fadeLabel = Label(self.controlPanel, text="fade:")
        self.fadeInput = Entry(self.controlPanel, width=3)
        self.fadeInput.insert(0, "1")
        self.fadeInput.config(state=DISABLED)
        self.fadeInput.bind("<KeyPress-Return>", self.inputValuesChanged)
        self.fadeInput.bind("<ButtonRelease>", self.updateGUI)

        self.standbyButton = Button(self.controlPanel, text="standby", command=self.toggleStandby)
        self.standbyButton.config(state=DISABLED)
        self.syncButton = Button(self.controlPanel, text="sync", command=self.sync)
        self.syncButton.config(state=DISABLED)
        self.reconnectButton = Button(self.controlPanel, text="reconnect", command=self.reconnect)

        self.cycle = IntVar()
        self.cycleButton = Checkbutton(
            self.controlPanel, text="use all projectors", variable=self.cycle, command=self.cycleToggled
        )

        self.brightnessScale = Scale(self.manualPanel, from_=0, to=100, resolution=1, label="brightness")
        self.brightnessScale.set(self.brightness)
        self.brightnessScale.bind("<ButtonRelease>", self.brightnessChanged)
        self.brightnessScale.config(state=DISABLED)
        self.brightnessScale.config(orient=HORIZONTAL)
        self.brightnessScale.config(length=400)

        self.gotoSlideScale = Scale(self.manualPanel, from_=0, to=self.controller.maxTray, label="goto slide")
        self.gotoSlideScale.set(1)
        self.gotoSlideScale.bind("<ButtonRelease>", self.gotoSlideChanged)
        self.gotoSlideScale.config(state=DISABLED)
        self.gotoSlideScale.config(orient=HORIZONTAL)
        self.gotoSlideScale.config(length=400)

        self.controlPanel.pack(side=BOTTOM, anchor=W, fill=X)
        self.projektorList.pack(side=LEFT, fill=BOTH)
        self.manualPanel.pack(side=RIGHT, expand=1, fill=BOTH)

        self.initButton.pack(side=LEFT, anchor=N, padx=4, pady=4)

        self.prevButton.pack(side=LEFT, anchor=N, padx=4, pady=4)
        self.nextButton.pack(side=LEFT, anchor=N, padx=4, pady=4)
        self.cycleButton.pack(side=LEFT, anchor=N, padx=4, pady=4)
        self.startButton.pack(side=LEFT, anchor=N, padx=4, pady=4)
        self.pauseButton.pack(side=LEFT, anchor=N, padx=4, pady=4)
        self.stopButton.pack(side=LEFT, anchor=N, padx=4, pady=4)
        self.timerLabel.pack(side=LEFT, anchor=N, padx=4, pady=4)
#.........这里部分代码省略.........
开发者ID:bullpup,项目名称:ektaprogui,代码行数:103,代码来源:ektaprogui.py

示例11: __init__

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import pack [as 别名]
class GUI:
    def __init__(self, model, title='PyCX Simulator', interval=0, stepSize=1,
            param_gui_names=None):
        self.model = model
        self.titleText = title
        self.timeInterval = interval
        self.stepSize = stepSize
        self.param_gui_names = param_gui_names
        if param_gui_names is None:
            self.param_gui_names = {}
        self.param_entries = {}
        self.statusStr = ""
        self.running = False
        self.modelFigure = None
        self.currentStep = 0

        self.initGUI()

    def initGUI(self):
        #create root window
        self.rootWindow = Tk()
        self.statusText = StringVar(value=self.statusStr)
        self.setStatusStr("Simulation not yet started")

        self.rootWindow.wm_title(self.titleText)
        self.rootWindow.protocol('WM_DELETE_WINDOW', self.quitGUI)
        self.rootWindow.geometry('550x700')
        self.rootWindow.columnconfigure(0, weight=1)
        self.rootWindow.rowconfigure(0, weight=1)

        self.frameSim = Frame(self.rootWindow)

        self.frameSim.pack(expand=YES, fill=BOTH, padx=5, pady=5, side=TOP)
        self.status = Label(self.rootWindow, width=40, height=3, relief=SUNKEN,
                            bd=1, textvariable=self.statusText)
        self.status.pack(side=TOP, fill=X, padx=1, pady=1, expand=NO)

        self.runPauseString = StringVar()
        self.runPauseString.set("Run")
        self.buttonRun = Button(self.frameSim, width=30, height=2,
                                textvariable=self.runPauseString,
                                command=self.runEvent)
        self.buttonRun.pack(side=TOP, padx=5, pady=5)

        self.showHelp(self.buttonRun,
                      "Runs the simulation (or pauses the running simulation)")
        self.buttonStep = Button(self.frameSim, width=30, height=2,
                                 text="Step Once", command=self.stepOnce)
        self.buttonStep.pack(side=TOP, padx=5, pady=5)
        self.showHelp(self.buttonStep, "Steps the simulation only once")
        self.buttonReset = Button(self.frameSim, width=30, height=2,
                                  text="Reset", command=self.resetModel)
        self.buttonReset.pack(side=TOP, padx=5, pady=5)
        self.showHelp(self.buttonReset, "Resets the simulation")

        for param in self.model.params:
            var_text = self.param_gui_names.get(param, param)
            can = Canvas(self.frameSim)
            lab = Label(can, width=25, height=1 + var_text.count('\n'),
                        text=var_text, anchor=W, takefocus=0)
            lab.pack(side='left')
            ent = Entry(can, width=11)
            val = getattr(self.model, param)
            if isinstance(val, bool):
                val = int(val)  # Show 0/1 which can convert back to bool
            ent.insert(0, str(val))
            ent.pack(side='left')
            can.pack(side='top')
            self.param_entries[param] = ent
        if self.param_entries:
            self.buttonSaveParameters = Button(self.frameSim, width=50,
                    height=1, command=self.saveParametersCmd,
                    text="Save parameters to the running model", state=DISABLED)
            self.showHelp(self.buttonSaveParameters,
                    "Saves the parameter values.\n" +
                    "Not all values may take effect on a running model\n" +
                    "A model reset might be required.")
            self.buttonSaveParameters.pack(side='top', padx=5, pady=5)
            self.buttonSaveParametersAndReset = Button(self.frameSim, width=50,
                    height=1, command=self.saveParametersAndResetCmd,
                    text="Save parameters to the model and reset the model")
            self.showHelp(self.buttonSaveParametersAndReset,
                    "Saves the given parameter values and resets the model")
            self.buttonSaveParametersAndReset.pack(side='top', padx=5, pady=5)

        can = Canvas(self.frameSim)
        lab = Label(can, width=25, height=1, text="Step size ", justify=LEFT,
                anchor=W, takefocus=0)
        lab.pack(side='left')
        self.stepScale = Scale(can, from_=1, to=500, resolution=1,
                               command=self.changeStepSize, orient=HORIZONTAL,
                               width=25, length=150)
        self.stepScale.set(self.stepSize)
        self.showHelp(self.stepScale,
                "Skips model redraw during every [n] simulation steps\n" +
                "Results in a faster model run.")
        self.stepScale.pack(side='left')
        can.pack(side='top')

        can = Canvas(self.frameSim)
#.........这里部分代码省略.........
开发者ID:thaije,项目名称:intro_comp_science,代码行数:103,代码来源:pycx_gui.py

示例12: resize

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import pack [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
from Tkinter import Tk, Label, Button, Scale, X, Y, HORIZONTAL

def resize(ev):
    test.config(font=('Consolas', ev))


top = Tk()
top.geometry('500x500')
Label(top, text='Directory list view').pack()

test = Label(top, text='test', fg='grey', font=('Consolas', 12))
test.pack()

scale = Scale(from_=10, to=40, orient=HORIZONTAL, command=resize)
scale.set(12)
scale.pack(fill=X)

Button(top, text='QUIT', bg='red', fg='blue', command=top.quit).pack(fill=X)

top.mainloop()
开发者ID:Sy-Dante,项目名称:py,代码行数:26,代码来源:Scale.py

示例13: Controller

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import pack [as 别名]
class Controller(Observer):
    def __init__(self,parent,view,lissajou,subjectSig,subjects):

        self.cursorFrame = Frame(parent)
        self.selectionFrame = Frame(self.cursorFrame)
        self.view = view
        self.lissajou = lissajou
        self.subjects = subjects
        self.subjectSig=subjectSig
        self.amp=IntVar()
        self.scale_amp=Scale(self.cursorFrame,variable=self.amp,
                          label="Amplitude",
                          orient="horizontal",length=250,from_=0,to=10,
                          sliderlength=50,tickinterval=1,showvalue=0,
                          command=self.update)
        self.freq=IntVar()
        self.scale_freq=Scale(self.cursorFrame,variable=self.freq,
                          label="Frequence",
                          orient="horizontal",length=250,from_=0,to=10,
                          sliderlength=50,tickinterval=0,showvalue=0,
                          command=self.update)
        self.offset=DoubleVar()
        self.scale_offset=Scale(self.cursorFrame,variable=self.offset,
                          label="Offset",
                          orient="horizontal",length=250,from_=-10.0,to=10.0,
                          sliderlength=50,tickinterval=5,showvalue=0,
                          command=self.update)

        self.phase=IntVar()
        self.scale_phase=Scale(self.cursorFrame,variable=self.phase,
                          label="Phase",
                          orient="horizontal",length=250,from_=-90,to=90,
                          sliderlength=10,tickinterval=45,showvalue=0,
                          command=self.update)


        self.voltVar = DoubleVar()
        self.voltVar.set(1)
        self.button1 = Radiobutton(self.selectionFrame, text="1V", variable=self.voltVar,
                                    value=1.0*5.0,command =lambda:self.update(None))
        self.button1.select()

        self.button2 = Radiobutton(self.selectionFrame, text="2V", variable=self.voltVar,
                                    value=2.0*5.0, command =lambda:self.update(None))

        self.button5 = Radiobutton(self.selectionFrame, text="5V", variable=self.voltVar,
                                    value=5.0*5.0, command =lambda:self.update(None))

        self.isOffsetVar= IntVar()
        self.isOffset = Checkbutton(self.selectionFrame,text = "Offset",variable = self.isOffsetVar,
                                    command =lambda:self.update(None))

    def update(self,event):
        self.update_amplitude(event)
        self.update_offset(event)
        self.update_frequency(event)
        self.update_phase(event)
        self.view.update()
        if self.lissajou!=None:
            self.lissajou.update()


    def update_amplitude(self,event):
        print("update_amplitude(self,event)",self.amp.get())
        self.subjectSig.set_magnitude(self.amp.get()/self.voltVar.get())
        self.subjects.generate_XYCurve()
    def update_frequency(self,event):
        print("update_frequency(self,event)",self.freq.get())
        self.subjectSig.set_frequency(self.freq.get())
        self.subjects.generate_XYCurve()
    def update_phase(self,event):
        print("update_phase(self,event)",self.phase.get())
        self.subjectSig.set_phase(self.phase.get())
        self.subjects.generate_XYCurve()
    def update_offset(self,event):
        if self.isOffsetVar.get():
            print("update_offset(self,event)",self.isOffsetVar.get())
            self.subjectSig.set_offset(self.offset.get()/self.voltVar.get())
            self.subjects.generate_XYCurve()
        else:
            self.subjectSig.set_offset(0.0)
            self.subjects.generate_XYCurve()

    def setLissajou(self,lissajou):
        self.lissajou = lissajou


    def packing(self) :
        self.selectionFrame.pack(side='top')
        self.button1.pack(side='left')
        self.button2.pack(side='left')
        self.button5.pack(side='left')
        self.isOffset.pack(side='left')
        self.cursorFrame.pack(side='left',expand=1, fill='both')
        self.scale_amp.pack()
        self.scale_freq.pack()
        self.scale_offset.pack()
        self.scale_phase.pack()
开发者ID:theMonarK,项目名称:Oscilloscope_Simulator,代码行数:100,代码来源:controls.py

示例14: Generator

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import pack [as 别名]
class Generator(Frame):
    """
    Vibration harmonique du type : e=a*sin(2*pi*f*t+p)

    scale_A : controleur d'Amplitude
    scale_F : controleur de Frequence
    scale_P : controleur de Phase

    """
    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 update_signal(self, event):
        """
        Mise a jour de signal si modifications (amplitude, frequence, phase)
        """
        print("Vibration.update_signal()")
        print("Amplitude :", self.scale_A.get())
        scaling=0.05
        amp = scaling*self.scale_A.get()
        signal = self.generate_signal(a=amp,f=self.scale_F.get(),
                                      p=self.scale_P.get())
        self.signal = signal
        if not isinstance(self.parent, Tk):
            self.parent.update_view(self.name, signal)
        self.parent.plot_all()
        return signal

    def generate_signal(self, a=1.0, f=2.0, p=0):
        """
        Calcul de l'elongation : e=a*sin(2*pi*f*t+p) sur une periode
        a : amplitude
        f : frequence
        p : phase
        """
        signal = []
        samples = 1000
        for t in range(0, samples):
            samples = float(samples)
            e = a * sin((2*pi*f*(t/samples)) - p)
            signal.append((t/samples,e))
        return signal
开发者ID:holiday2018,项目名称:python_oscilloscope,代码行数:77,代码来源:generator.py

示例15: Scale

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import pack [as 别名]
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, from_=0, to=100,orient=HORIZONTAL,label="Decay",relief = FLAT)

#Sets initial FDL constant values
timeInput.set(100)
springInput.set(250)
coulombInput.set(500)
decayInput.set(90)

#Initializes the canvas for animation 
canvas = Canvas(width=width, height=height, bg="#f0f0f0")
canvas.pack(fill = "both", expand = 1, padx=50)

#Adds teh sliders to the tkinter frame after the canvas for positioning
timeInput.pack(side=LEFT, padx=50, pady=10)
springInput.pack(side=LEFT, padx=50, pady=10)
coulombInput.pack(side=LEFT, padx=50, pady=10)
decayInput.pack(side=LEFT, padx=50, pady=10)

#Smallest node size in pixels
RADIUS = 5


#Calculates the euclidean distance between an oval and a point
def distance(x,y, coords):
    x0, y0, x1, y1 = coords # tuple (x0,y0,x1,y1)
    x2 = (x0 + x1) / 2.0
    y2 = (y0 + y1) / 2.0
    return ( (x - x2)**2 + (y - y2)**2 ) ** 0.5
开发者ID:dgriff03,项目名称:deBruijnFDL,代码行数:32,代码来源:debruijn.py


注:本文中的Tkinter.Scale.pack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。