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


Python Scale.set方法代码示例

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


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

示例1: JoystickFrame

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import set [as 别名]
class JoystickFrame(LabelFrame):
    def __init__(self, master, tracker, text="Joystick", **options):
        LabelFrame.__init__(self, master, text=text, **options)
        self.tracker = tracker

        self.width = 400
        self.height = 400
        self.canvas = Canvas(self, height=self.height, width=self.width)
        self.canvas.grid()
        self.canvas.create_oval((self.width/2 - 3, self.height/2 - 3,
                                 self.width/2 + 3, self.height/2 + 3))
        self.canvas.bind("<Button-1>",
                         bg_caller(lambda event: self.move_tracker(event)))
        self.canvas.bind("<Motion>", self.update_label)

        self.motion_label = Label(self, text="",
                                  font=tkFont.Font(family="Courier"))
        self.motion_label.grid()

        f = LabelFrame(self, text="Sensitivity")
        self.sensitivity_scale = Scale(f, from_=0, to=10,
                                       resolution=0.01,
                                       orient=HORIZONTAL,
                                       length=self.width)
        self.sensitivity_scale.set(5)
        self.sensitivity_scale.grid()
        f.grid()

    @property
    def sensitivity(self):
        return self.sensitivity_scale.get() / 2000.

    def get_delta(self, event):
        dx = event.x - int(self.canvas['width'])/2.
        dy = event.y - int(self.canvas['height'])/2.
        dx_rad = dx*self.sensitivity
        dy_rad = dy*self.sensitivity
        dtheta = dy_rad
        dphi = -dx_rad
        return (dtheta, dphi)

    def update_label(self, event):
        dtheta, dphi = self.get_delta(event)
        self.motion_label.configure(text="<{:8.5f}, {:8.5f}>".format(dtheta,
                                                                     dphi))

    def move_tracker(self, event):
        dtheta, dphi = self.get_delta(event)
        self.tracker.move(0, dtheta, dphi)
        logger.info("Moved tracker by ({}, {})".format(dtheta, dphi))
开发者ID:ucsbdeepspace,项目名称:morphable-mirror-telescope-python,代码行数:52,代码来源:joystickframe.py

示例2: FDL

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import set [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

示例3: Logplayer

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import set [as 别名]
class Logplayer(Frame):
    def __init__(self, root, logfn, viewer, analyzator=None, logdir=None, **kwargs):
        self.root=root
        self.logdir = logdir
        self.analyzator = analyzator
        if not self.logdir:
            self.logdir=os.path.join(os.path.dirname(os.path.dirname(__file__)),'log')
        Frame.__init__(self, **kwargs)
        self.view=viewer(self, x=800, y=600, onLeft=self.clickL, onRight=self.clickR)
        self.createWidgets()
        self.bind_all("<Left>", self.prev)
        self.bind_all("<Right>", self.next)

        self.view.redraw()
        self.root.update()
        if not logfn:
            logfn = self.logSelectDialog()
        self.dirname, self.filename = os.path.split(logfn)
        self.startRun(logfn,0)
        self.view.redraw()
        self.root.after(10,self.view.zoomExtens)
        self.running=False

    def logSelectDialog(self):
            self.root.update()
            timestamps, dirs, fns = zip(*sorted(listdir(self.logdir), reverse=True))
            o=SelcectDialog(self.root, "select log", timestamps)
            self.root.wait_window(o.top)
            index=timestamps.index(o.option)
            return os.path.join(dirs[index], fns[index])

    def createWidgets(self):
        self.controlFrame=Frame(self)
        self.posScale = Scale(self.controlFrame, orient='horizontal',
                           length=210,
                           from_=0, tickinterval=0,
                           command=self.pos_callback,
                           showvalue=0,sliderlength=10, resolution=1)
        #self.posScale.bind('<Button-1>',self.pos_start_drag)
        #self.posScale.bind('<ButtonRelease-1>', self.pos_set)

        self.playB=Button(self.controlFrame, text="play", command=self.playToggle)
        self.nextB=Button(self.controlFrame, text="next", command=self.nextRun)
        self.prevB=Button(self.controlFrame, text="prev", command=self.prevRun)
        self.camera=tkimg(self, width=640, height=512)
        self.controlFrame.grid(row=0,column=1, sticky="nw")
        self.view.grid(row=1, column=1, sticky="nsew")
        self.grid_columnconfigure(1,weight=1)
        self.grid_rowconfigure(1,weight=1)
        self.camera.grid(row = 1, column = 2, sticky = 'ne')
        self.playB.grid(row=0, column=1)
        self.prevB.grid(row=0, column=2)
        self.nextB.grid(row=0, column=3)
        self.posScale.grid(row=0, column=0)


    def playToggle(self, *args):
        if self.running:
            self.root.after_cancel(self.cycleId)
        else:
            self.cycleId=self.root.after(20, self.showrun)
        self.running=not self.running

    def nextRun(self, *args):
        self.changeRun(1)

    def prevRun(self, *args):
        self.changeRun(-1)

    def changeRun(self, step):
        if self.running:
            self.root.after_cancel(self.cycleId)
            self.running=False
        run=self.loggenerator.run+step
        if run >= len(self.loggenerator.runconfig) or run<0:
            timestamps, dirs, fns = zip(*sorted(listdir(self.logdir)))
            index=fns.index(self.filename)+step
            if 0<=index<len(fns):
                run = 0 if step==1 else -1
                self.startRun(os.path.join(dirs[index], fns[index]), run)
        else:
            self.startRun(os.path.join(self.dirname, self.filename), run)




    def restart(self, keeppostion=True, startposition=None):
        self.loggenerator.startrun(self.loggenerator.run, startposition=startposition)
        self.data=list(self.loggenerator)
        if not keeppostion:
            self.position=0
        self.posScale.set(self.position)
        self.showData(self.position)

    def startRun(self, fn, run, keeppostion=False):
        self.dirname, self.filename = os.path.split(fn)
        print("starting log %s run %i"%(fn,run))
        self.loggenerator=EduroMaxiReader(fn)
        self.loggenerator.startrun(run)
        self.root.title("%s %s run %i"%(self.dirname,self.filename, self.loggenerator.run+1))
#.........这里部分代码省略.........
开发者ID:robotika,项目名称:eduro,代码行数:103,代码来源:logplayer.py

示例4: Scraper

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

    def __init__(self, img_filename='snap.png'):
        self.canvas = Canvas()
        self.scales = []
        self.canvas.pack()
        self._current_image = None
        self._original_image = None
        
        self.root = self._load_gui()
        self.open_image(img_filename)
        self.repaint()
        self.root.mainloop()

    @property
    def image(self):
        return self._current_image

    @image.setter
    def image(self, value):
        self._current_image = value

    @property
    def original_image(self):
        return self._original_image

    @image.setter
    def image(self, value):
        self._original_image = value

    def open_image(self, filename):
        self.original_image = Image.open(filename).copy()
        self.image = self.original_image

    def repaint(self):
        rgb_min = (self.scale_red_min.get(), self.scale_green_min.get(), self.scale_blue_min.get())
        rgb_max = (self.scale_red_max.get(), self.scale_green_max.get(), self.scale_blue_max.get())
        print "repainting", rgb_min, rgb_max
        self.image = strip_colors(self.original_image, rgb_min, rgb_max)
        self._paint(self.image)

    def _paint(self, image):
        if image is not None:
            # check if we need to resize the canvas, based on the size of the image being painted
            image_width, image_height = image.size
            if self.canvas.winfo_width() != image_width or self.canvas.winfo_height() != image_height:
                self.canvas.config(width=image_width, height=image_height)

            # paint the image to the canvas
            self._img_tk = ImageTk.PhotoImage(image)
            self.canvas.create_image(0, 0, image=self._img_tk, anchor=NW)
        else:
            print 'there is no image to paint'
            return -1
 
    def _load_gui(self):
        root = Tk()
        root.title("Scraper")
        main_frame = Frame(root)
        main_frame.grid(column=0, row=0, sticky=(N, W, E, S))
        main_frame.columnconfigure(0, weight=1)
        main_frame.rowconfigure(0, weight=1)
        main_frame.pack()
        
        self.scale_red_min = Scale(main_frame, from_=0, to=255, orient=HORIZONTAL, command=self._update_red_min)
        self.scale_red_min.grid(column=1, row=1)
       
        self.scale_red_max = Scale(main_frame, from_=0, to=255, orient=HORIZONTAL, command=self._update_red_max)
        self.scale_red_max.grid(column=2, row=1)
        self.scale_red_max.set(255)
        
        self.scale_green_min = Scale(main_frame, from_=0, to=255, orient=HORIZONTAL, command=self._update_green_min)
        self.scale_green_min.grid(column=1, row=2)

        self.scale_green_max = Scale(main_frame, from_=0, to=255, orient=HORIZONTAL, command=self._update_green_max)
        self.scale_green_max.grid(column=2, row=2)
        self.scale_green_max.set(255)

        self.scale_blue_min = Scale(main_frame, from_=0, to=255, orient=HORIZONTAL, command=self._update_blue_min)
        self.scale_blue_min.grid(column=1, row=3)
        
        self.scale_blue_max = Scale(main_frame, from_=0, to=255, orient=HORIZONTAL, command=self._update_blue_max)
        self.scale_blue_max.grid(column=2, row=3)
        self.scale_blue_max.set(255)
        return root

    def _update_red_min(self, value):
        print 'updating red min to %s' % value
        if self.scale_red_min.get() > self.scale_red_max.get():
            self.scale_red_max.set(self.scale_red_min.get())
        self.repaint()

    def _update_red_max(self, value):
        print 'updating red max to %s' % value
        if self.scale_red_max.get() < self.scale_red_min.get():
            self.scale_red_min.set(self.scale_red_max.get())
        self.repaint()

    def _update_green_min(self, value):
        print 'updating green min to %s' % value
#.........这里部分代码省略.........
开发者ID:protobuf,项目名称:dsbot,代码行数:103,代码来源:scraper.py

示例5: changescale

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import set [as 别名]
root.bind("<Key-plus>", lambda ev: changescale(0.15))
root.bind("<Key-minus>", lambda ev: changescale(-0.15))

amountvars = {}  # each light name maps to a Tkinter.DoubleVar object which the Scale adjusts


def redraw(*args):
    global l, amountvars, update
    # read the value out of each Scale
    amounts = dict([(k, v.get()) for k, v in amountvars.items()])
    mix.setamounts(amounts)


for x in mix.lightnames():
    # the Scale sets this; the redraw() callback reads it
    amountvars[x] = DoubleVar()

    # a new frame for each slider row
    f = Frame(root, bd=1, relief="groove")
    f.pack(fill="x", expand=1)
    # title
    Label(f, text=x, width=10, anchor="e").pack(side="left")
    # slider
    s = Scale(f, from_=0, to=1, res=0.01, orient="horiz", variable=amountvars[x], command=redraw)
    s.pack(side="left", fill="x", expand=1)
    if x == "ambient":  # the 'ambient' level (if present) starts at 1
        s.set(1)

root.mainloop()
开发者ID:shakaran,项目名称:light9,代码行数:31,代码来源:lightsim.py

示例6: VRConfigDialog

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import set [as 别名]
class VRConfigDialog(Dialog):
    """
    Defines a custom dialog for editing the Virtual Reality params
    """
    def __init__(self, parent, populator=None, manager=None):
        """
        Construct the dialog
        """
        self._entries = {
            "frame_angle"    : None,
            "distortion"     : False,
            "windowed"      : False,
            "eye_height"     : None,
            "minimum_dist_to_wall"  : None

        }
        self._win_var = IntVar(0)
        self._distortion_var = IntVar(0)
        Dialog.__init__(self, parent=parent, title="VRConfiguration", populator=populator, manager=manager)

    def body(self, parent):
        """
        Overridden method defining the body of the dialog
        :param parent:
        :return:
        """

        # Define all of the labels for our options
        Label(parent, text="Frame Angle:", padx=3, anchor=SW, height=2).grid(row=0, column=0, sticky=W)
        Label(parent, text="Eye Height:", padx=3, anchor=SW, height=2).grid(row=1, column=0, pady=2, sticky=W )
        Label(parent, text="MinDistToWall:", padx=3, anchor=SW, height=2).grid(row=2, column=0, pady=2,  sticky=W)
        Label(parent, text="Distortion:", padx=3).grid(row=3, column=0, pady=2, sticky=W)
        Label(parent, text="Windowed:", padx=3).grid(row=4, column=0, pady=2, sticky=W)

        # Define the sub-widgets that the labels are referring to
        self._frameAngle = Scale(parent, from_=-20, to=20, orient=HORIZONTAL)
        if self._entries["frame_angle"] is not None:
            self._frameAngle.set(self._entries["frame_angle"])
        else:
            self._frameAngle.set(-5)
        self._frameAngle.grid(row=0, column=1, padx=3)

        self._eyeHeight = Scale(parent, from_=0, to=500, orient=HORIZONTAL)
        if self._entries["eye_height"] is not None:
            self._eyeHeight.set( self._entries["eye_height"] )
        else:
            self._eyeHeight.set(50)
        self._eyeHeight.grid(row=1, column=1, padx=3)

        self._minDistToWall = Scale(parent, from_=1, to=300, orient=HORIZONTAL)
        if self._entries["minimum_dist_to_wall"] is not None:
            self._minDistToWall.set( self._entries["minimum_dist_to_wall"] )
        else:
            self._minDistToWall.set(20)
        self._minDistToWall.grid(row=2, column=1, padx=3)

        self._distortion = Checkbutton(parent, variable=self._distortion_var, offvalue=0, onvalue=1, text="Enable", command=self._toggle_distortion)
        self._distortion.grid(row=3, column=1, padx=3)

        self._windowed = Checkbutton(parent, variable=self._win_var, offvalue=0, onvalue=1, text="Enable", command=self._toggle_windowed)
        self._windowed.grid(row=4, column=1, padx=3)

    def _toggle_distortion(self):
        """
        Toggle the distortion flag
        :return:
        """
        self._distortion_var.set(0 if self._distortion_var.get() == 1 else 1)
        val = self._entries["distortion"]
        self._entries["distortion"] = not val
        Debug.printi("Distortion toggled to " + (str(not val)), Debug.Level.INFO)
        self._distortion.toggle()

    def _toggle_windowed(self):
        """
        Toggle the windowed flag
        :return:
        """
        self._win_var.set(0 if self._win_var.get() == 1 else 1)
        val = self._entries["windowed"]
        self._entries["windowed"] = not val
        Debug.printi("Windowing toggled to " + (str(not val)), Debug.Level.INFO)
        self._windowed.toggle()

    def populate(self, manager):
        self._entries["frame_angle"]            = manager.frame_angle
        self._entries["distortion"]             = manager.distortion
        self._entries["windowed"]               = manager.windowed
        self._entries["eye_height"]             = manager.eye_height
        self._entries["minimum_dist_to_wall"]   = manager.minimum_dist_to_wall
        self._win_var.set( 0 if manager.windowed is False else 1 )
        self._distortion_var.set( 0 if manager.distortion is False else 1 )

    def validate(self):
        (result, message) = DataValidator.validate(DataStore.EVENT.VR_EDIT, self._entries)
        if result is not True:
            tkMessageBox.showerror("Input Error", message)
        return result

    def apply(self):
#.........这里部分代码省略.........
开发者ID:twisty-n,项目名称:MazeBuilder,代码行数:103,代码来源:DiaDoges.py

示例7: SPIFrame

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import set [as 别名]
class SPIFrame(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)   
        self.parent = parent
        self.initialize()
        
    def initialize(self):
        self.grid()
        self.entryVariable = StringVar()
        self.entry = Entry(self, textvariable=self.entryVariable)
        self.entry.grid(column=0,row=0,sticky='EW')
        self.entry.bind("<Return>", self.OnPressEnter)

        button = Button(self,text="SPI send", command=self.OnButtonClick)
        button.grid(column=1,row=0)
        
        #ramp = Button(self,text="RAMP", command=self.setlabvar)
        #ramp.grid(column=1,row=1)        

        self.labelVariable = StringVar()
        label = Label(self,textvariable=self.labelVariable,
                              anchor="w",fg="white",bg="blue")
        label.grid(column=0,row=1,columnspan=1,sticky='EW')
        self.labelVariable.set("Start..")
        
        self.slider = Scale(self, from_=0, to=80, orient=HORIZONTAL, 
                            command=self.setlabvar)
        self.slider.grid(column=0, row=2, columnspan=3, sticky='EW')
        
        self.PID = PIDTune(self)
        self.PID.grid(column=0, row=3, columnspan=3, sticky='EW')
        
        self.grid_columnconfigure(0,weight=1)
        self.update()
        #self.geometry(self.geometry()) # caused busy wait?
        self.entry.focus_set()
        #self.entry.selection_range(0, Tkinter.END) # caused busy wait?
        

        
        
    def setlabvar(self, val):
        val = self.slider.get()
        speed.SetAcceleration(val)
        accel = val;
        self.labelVariable.set("Duty set: " + str(val) )       
        

    def OnButtonClick(self):
        accel = int(self.entryVariable.get())
        self.slider.set(accel)
        speed.SetAcceleration(accel)
        self.labelVariable.set("Duty set: " + str(accel) )
        self.entry.focus_set()
        self.entry.selection_range(0, END)
        
    def OnPressEnter(self,event):
        accel = int(self.entryVariable.get())
        self.slider.set(accel)
        speed.SetAcceleration(accel)
        self.labelVariable.set("Duty set: " + str(accel) )
        self.entry.focus_set()
        self.entry.selection_range(0, END)
开发者ID:NissankaW,项目名称:Mariokart3,代码行数:65,代码来源:GUI.py

示例8: ToolBar

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import set [as 别名]
class ToolBar(Frame):
	def __init__(self, root, printer, settings, logger, *arg):
		self.app = root
		self.printer = printer
		self.settings = settings
		self.logger = logger
		
		self.app.printing = False
		self.app.connected = False
		self.app.paused = False
		
		Frame.__init__(self, root, *arg)
		topBar = Frame(self)
		topBar.grid(row=1, column=1, columnspan=3, sticky=W)
		speedBar = Frame(self)
		speedBar.grid(row=1, column=5, sticky=E)
		bottomBar = Frame(self)
		bottomBar.grid(row=2, column=1, columnspan=6, sticky=W+E)
		
		self.bPort = Button(topBar, text="Port", width=BWIDTH, command=self.doPort)
		self.bPort.pack(side=LEFT, padx=2, pady=2)
		ports = self.scanSerial()
		self.spPort = Spinbox(topBar, values=ports, state="readonly")
		self.spPort.pack(side=LEFT, padx=2, pady=2)
		l = Label(topBar, text=" @ ")
		l.pack(side=LEFT, padx=2, pady=2)
		self.spBaud = Spinbox(topBar, values=baudChoices)
		self.spBaud.pack(side=LEFT, padx=2, pady=2)
		self.spBaud.delete(0, END)
		self.spBaud.insert(0, 115200)
		self.spBaud.config(state="readonly")

		self.bConnectMode = CM_CONNECT
		self.bConnect = Button(topBar, text=connectText[CM_CONNECT], width=BWIDTH, command=self.doConnect)
		self.bConnect.pack(side=LEFT, padx=2, pady=2)
		if len(ports) == 0:
			self.bConnect.config(state=DISABLED)
		else:
			self.bConnect.config(state=NORMAL)


		self.bReset = Button(topBar, text="Reset", width=BWIDTH, command=self.doReset, state=DISABLED)
		self.bReset.pack(side=LEFT, padx=2, pady=2)
		
		l = Label(speedBar, text="Speed:", justify=RIGHT)
		l.grid(row=1, column=1, sticky=E)

		self._speedJob = None		
		self.currentSpeed = self.app.FeedMultiply
		self.scSpeed = Scale(speedBar, from_=MINSPEED, to=MAXSPEED, orient=HORIZONTAL, command=self.updateSpeedCommand)
		self.scSpeed.grid(row=1, column=2)
		self.scSpeed.set(self.currentSpeed);

		l = Label(speedBar, text="Fan:", width=10, anchor=E, justify=RIGHT)
		l.grid(row=1, column=3, sticky=E)
		
		self._fanJob = None		
		self.currentFanSpeed = self.app.FanSpeed
		self.scFan = Scale(speedBar, from_=0, to=255, orient=HORIZONTAL, command=self.updateFanSpeedCommand)
		self.scFan.grid(row=1, column=4)
		self.scFan.set(self.currentFanSpeed);

		if self.settings.speedcommand is not None:
			self.cbvAssertFan = IntVar()
			if self.settings.forcefanspeed:
				self.cbvAssertFan.set(1)
			else:
				self.cbvAssertFan.set(0)
			self.cbAssertFan = Checkbutton(speedBar, text="Force", variable=self.cbvAssertFan,
				command=self.clickAssertFan)
			self.cbAssertFan.grid(row=1, column=5)

		self.bSliceMode = SM_SLICE
		self.bSlice = Button(bottomBar, text=sliceText[SM_SLICE], width=BWIDTH*2, command=self.doSlice)
		self.bSlice.pack(side=LEFT, padx=2, pady=2)
		
		self.bLoad = Button(bottomBar, text="Load GCode", width=BWIDTH, command=self.doLoad)
		self.bLoad.pack(side=LEFT, padx=2, pady=2)
		self.setSliceText()
		
		self.bSD = Button(bottomBar, text="SD", width=BWIDTH, command=self.doSD, state=DISABLED)
		self.bSD.pack(side=LEFT, padx=2, pady=2)
		
		self.bPrintMode = PR_PRINT		
		self.bPrint = Button(bottomBar, text=printText[PR_PRINT], width=BWIDTH, command=self.doPrint, state=DISABLED)
		self.bPrint.pack(side=LEFT, padx=2, pady=2)
		
		self.bPauseMode = PM_PAUSE
		self.bPause = Button(bottomBar, text=pauseText[PM_PAUSE], width=BWIDTH, command=self.doPause, state=DISABLED)
		self.bPause.pack(side=LEFT, padx=2, pady=2)

		self.bAbandon = Button(bottomBar, text="Abandon SD Print", width=BWIDTH+8, command=self.doAbandon, state=DISABLED)
		self.bAbandon.pack(side=LEFT, padx=2, pady=2)
		
		self.cbvLiftOnPause = IntVar()
		if self.settings.liftonpause:
			self.cbvLiftOnPause.set(1)
		else:
			self.cbvLiftOnPause.set(0)
		self.cbLiftOnPause = Checkbutton(bottomBar, text="Lift Head/Retract on Pause", variable=self.cbvLiftOnPause,
#.........这里部分代码省略.........
开发者ID:jbernardis,项目名称:repraphost,代码行数:103,代码来源:toolbar.py

示例9: OfflineVisualiser

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import set [as 别名]
class OfflineVisualiser(Visualiser):
    """A VTK-powered offline visualiser which runs in its own thread.
    In addition to the functions provided by the standard visualiser,
    the following additional functions are provided:

    precache_height_quantities() - Precache all the vtkpoints
    structures for any dynamic height based quantities to render.
    """
    def __init__(self, source, frameDelay=100, frameStep=1):
        """The source parameter is assumed to be a NetCDF sww file.
        The frameDelay parameter is the number of milliseconds waited between frames.
        """
        Visualiser.__init__(self, source)

        self.frameNumber = 0
        fin = NetCDFFile(self.source, 'r')
        self.maxFrameNumber = fin.variables['time'].shape[0] - 1
        fin.close()
        
        #self.frameNumberTkVariable = StringVar()
        #self.frameNumberTkVariable.set('Frame - %05g'%self.framNumber)

        self.frameDelay = frameDelay

        self.xmin = None
        self.xmax = None
        self.ymin = None
        self.ymax = None
        self.zmin = None
        self.zmax = None

        self.frameStep= frameStep 

        self.vtk_heightQuantityCache = []
        for i in range(self.maxFrameNumber + 1): # maxFrameNumber is zero indexed.
            self.vtk_heightQuantityCache.append({})

        self.paused = False
        self.movie = False
        
    def setup_grid(self):
        fin = NetCDFFile(self.source, 'r')
        self.vtk_cells = vtkCellArray()
        N_tri = fin.variables['volumes'].shape[0]
        for v in range(N_tri):
            self.vtk_cells.InsertNextCell(3)
            for i in range(3):
                self.vtk_cells.InsertCellPoint(fin.variables['volumes'][v][i])
        fin.close()
        
    def update_height_quantity(self, quantityName, dynamic=True):
        polydata = self.vtk_polyData[quantityName] = vtkPolyData()
        if dynamic is True:
            #print ' - Frame',self.frameNumber,'of',self.maxFrameNumber
            if not self.vtk_heightQuantityCache[self.frameNumber].has_key(quantityName):
                self.vtk_heightQuantityCache[self.frameNumber][quantityName]\
                    = self.read_height_quantity(quantityName, True, self.frameNumber);
            polydata.SetPoints(self.vtk_heightQuantityCache[self.frameNumber][quantityName])
        else:
            polydata.SetPoints(self.read_height_quantity(quantityName, False))
        polydata.SetPolys(self.vtk_cells)

    def get_3d_bounds(self):
        return [self.xmin, self.xmax, self.ymin, self.ymax, self.zmin, self.zmax]
            
    def read_height_quantity(self, quantityName, dynamic=True, frameNumber=0):
        """Read in a height based quantity from the NetCDF source file
        and return a vtkPoints object. frameNumber is ignored if
        dynamic is false."""
        fin = NetCDFFile(self.source, 'r')
        points = vtkPoints()
        if dynamic is True:
            N_vert = fin.variables[quantityName].shape[1]
        else:
            N_vert = len(fin.variables[quantityName])
        x = num.ravel(num.array(fin.variables['x'], num.float))
        y = num.ravel(num.array(fin.variables['y'], num.float))
        if dynamic is True:
            q = num.array(fin.variables[quantityName][frameNumber], num.float)
        else:
            q = num.ravel(num.array(fin.variables[quantityName], num.float))

        q *= self.height_zScales[quantityName]
        q += self.height_offset[quantityName]

        for v in range(N_vert):
            points.InsertNextPoint(x[v], y[v], q[v])
            if self.xmin == None or self.xmin > x[v]:
                self.xmin = x[v]
            if self.xmax == None or self.xmax < x[v]:
                self.xmax = x[v]
            if self.ymin == None or self.ymin > y[v]:
                self.ymin = y[v]
            if self.ymax == None or self.ymax < y[v]:
                self.ymax = y[v]
            if self.zmin == None or self.zmin > q[v]:
                self.zmin = q[v]
            if self.zmax == None or self.zmax < q[v]:
                self.zmax = q[v]
        fin.close()
#.........这里部分代码省略.........
开发者ID:MattAndersonPE,项目名称:anuga_core,代码行数:103,代码来源:offline.py

示例10: Cockpit

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import set [as 别名]

#.........这里部分代码省略.........
                             relief=SUNKEN)
        self._shiftCanvas.bind("<Button-1>", self._onMouseButton1)
        #self._shiftCanvas.bind("<ButtonRelease-1>", self._onMouseButtonRelease1)
        self._shiftCanvas.bind("<B1-Motion>", self._onMouseButton1Motion)
        self._shiftCanvas.bind("<Double-Button-1>", self._onMouseDoubleButton1)

        self._shiftCanvas.bind("<Button-3>", self._onMouseButton3)
        #self._shiftCanvas.bind("<ButtonRelease-3>", self._onMouseButtonRelease3)
        self._shiftCanvas.bind("<B3-Motion>", self._onMouseButton3Motion)

        self._shiftCanvas.grid(row=0,column=1, padx=2, pady=2)
        self._shiftCanvas.create_oval(1, 1, 400, 400, outline="#ff0000")
        self._shiftCanvas.create_line(200, 2, 200, 400, fill="#ff0000")
        self._shiftCanvas.create_line(2, 200, 400, 200, fill="#ff0000")
        self._shiftMarker = self._shiftCanvas.create_oval(196, 196, 204, 204, outline="#0000ff", fill="#0000ff")
        
        self._yaw = DoubleVar()
        self._yawScale = Scale(controlFrame, orient=HORIZONTAL, from_=-100.0, to=100.0, \
                            tickinterval=0, variable=self._yaw, \
                            length=200, showvalue=1, \
                            command=self._onYawScaleChanged)
        self._yawScale.bind("<Double-Button-1>", self._onYawScaleDoubleButton1, "+")
        self._yawScale.grid(row=1, column=1)
        
        self._controlKeyActive = False
        

        #PID calibration

        pidCalibrationFrame = tkFrame(self)
        pidCalibrationFrame.grid(column=0, row=2, sticky="WE");

        self._pidSelected = StringVar()
        self._pidSelected.set("--")
        self._pidListBox = OptionMenu(pidCalibrationFrame, self._pidSelected, "--", \
                                      Cockpit.KEY_ANG_SPEED, Cockpit.KEY_ANGLES, Cockpit.KEY_ACCEL, \
                                       command=self._onPidListBoxChanged)
        self._pidListBox.pack(side=LEFT, padx=2)
        self._pidListBox.config(width=10)
        
        self._axisSelected = StringVar()
        self._axisSelected.set("--")
        self._axisListBox = OptionMenu(pidCalibrationFrame, self._axisSelected, "--", "X", "Y", "Z", \
                                       command=self._onAxisListBoxChanged)
        self._axisListBox.pack(side=LEFT, padx=2)
        self._axisListBox.config(state=DISABLED)

        Label(pidCalibrationFrame, text="P").pack(side=LEFT, padx=(14, 2))

        self._pidPString = StringVar()
        self._pidPString.set("0.00")
        self._pidPSpinbox = Spinbox(pidCalibrationFrame, width=5, from_=0.0, to=10000.0, increment=0.01, state=DISABLED, \
                                         textvariable=self._pidPString, command=self._onPidSpinboxChanged)
        self._pidPSpinbox.pack(side=LEFT, padx=2)

        Label(pidCalibrationFrame, text="I").pack(side=LEFT, padx=(14, 2))

        self._pidIString = StringVar()
        self._pidIString.set("0.00")
        self._pidISpinbox = Spinbox(pidCalibrationFrame, width=5, from_=0.0, to=10000.0, increment=0.01, state=DISABLED, \
                                         textvariable=self._pidIString, command=self._onPidSpinboxChanged)
        self._pidISpinbox.pack(side=LEFT, padx=2)
        
        Label(pidCalibrationFrame, text="D").pack(side=LEFT, padx=(14, 2))
        
        self._pidDString = StringVar()
开发者ID:dpm76,项目名称:eaglebone,代码行数:70,代码来源:cockpit.py

示例11: EktaproGUI

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import set [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

示例12: Cockpit

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import set [as 别名]

#.........这里部分代码省略.........
                             relief=SUNKEN)
        self._shiftCanvas.bind("<Button-1>", self._onMouseButton1)
        #self._shiftCanvas.bind("<ButtonRelease-1>", self._onMouseButtonRelease1)
        self._shiftCanvas.bind("<B1-Motion>", self._onMouseButton1Motion)
        self._shiftCanvas.bind("<Double-Button-1>", self._onMouseDoubleButton1)

        self._shiftCanvas.bind("<Button-3>", self._onMouseButton3)
        #self._shiftCanvas.bind("<ButtonRelease-3>", self._onMouseButtonRelease3)
        self._shiftCanvas.bind("<B3-Motion>", self._onMouseButton3Motion)

        self._shiftCanvas.grid(row=0,column=1, padx=2, pady=2)
        self._shiftCanvas.create_oval(2, 2, 400, 400, outline="#ff0000")
        self._shiftCanvas.create_line(201, 2, 201, 400, fill="#ff0000")
        self._shiftCanvas.create_line(2, 201, 400, 201, fill="#ff0000")
        self._shiftMarker = self._shiftCanvas.create_oval(197, 197, 205, 205, outline="#0000ff", fill="#0000ff")
        
        self._yaw = DoubleVar()
        self._yawScale = Scale(controlFrame, orient=HORIZONTAL, from_=-100.0, to=100.0, \
                            tickinterval=0, variable=self._yaw, \
                            length=200, showvalue=1, \
                            command=self._onYawScaleChanged)
        self._yawScale.bind("<Double-Button-1>", self._onYawScaleDoubleButton1, "+")
        self._yawScale.grid(row=1, column=1)
        
        self._controlKeyActive = False
        

        #PID calibration

        pidCalibrationFrame = tkFrame(self)
        pidCalibrationFrame.grid(column=0, row=2, sticky="WE");

        self._pidSelected = StringVar()
        self._pidSelected.set("--")
        self._pidListBox = OptionMenu(pidCalibrationFrame, self._pidSelected, "--", \
                                      Cockpit.KEY_ANG_SPEED, Cockpit.KEY_ANGLES, Cockpit.KEY_ACCEL, \
                                       command=self._onPidListBoxChanged)
        self._pidListBox.pack(side=LEFT, padx=2)
        self._pidListBox.config(width=10)
        
        self._axisSelected = StringVar()
        self._axisSelected.set("--")
        self._axisListBox = OptionMenu(pidCalibrationFrame, self._axisSelected, "--", "X", "Y", "Z", \
                                       command=self._onAxisListBoxChanged)
        self._axisListBox.pack(side=LEFT, padx=2)
        self._axisListBox.config(state=DISABLED)

        Label(pidCalibrationFrame, text="P").pack(side=LEFT, padx=(14, 2))

        self._pidPString = StringVar()
        self._pidPString.set("0.00")
        self._pidPSpinbox = Spinbox(pidCalibrationFrame, width=5, from_=0.0, to=100.0, increment=0.01, state=DISABLED, \
                                         textvariable=self._pidPString, command=self._onPidSpinboxChanged)
        self._pidPSpinbox.pack(side=LEFT, padx=2)

        Label(pidCalibrationFrame, text="I").pack(side=LEFT, padx=(14, 2))

        self._pidIString = StringVar()
        self._pidIString.set("0.00")
        self._pidISpinbox = Spinbox(pidCalibrationFrame, width=5, from_=0.0, to=100.0, increment=0.01, state=DISABLED, \
                                         textvariable=self._pidIString, command=self._onPidSpinboxChanged)
        self._pidISpinbox.pack(side=LEFT, padx=2)
        
        Label(pidCalibrationFrame, text="D").pack(side=LEFT, padx=(14, 2))
        
        self._pidDString = StringVar()
开发者ID:hisie,项目名称:eaglebone,代码行数:70,代码来源:cockpit.py

示例13: EnviroDialog

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import set [as 别名]
class EnviroDialog(Dialog):
    """
    Dialog for editing the simulation environment details
    """
    def __init__(self, parent, populator=None, manager=None):
        """
        Construct the dialog
        :param parent:          The tk element that is the parent of the dialog
        :return:                An instance of EnviroDialog
        """
        self._entries = {
            "floor_texture": None,
            "wall_height": None,
            "edge_width": None,
            "sky_texture": None,
            "start_node": None
        }
        Dialog.__init__(self, parent=parent, title="EnvironmentConfiguration", populator=populator, manager=manager)

    def body(self, parent):
        """
        Overridden method defining the body of the dialog
        :param parent:
        :return:
        """
        self._floorSel = ImagePicker(parent, "Floor Texture:",
                                     default=self._entries["floor_texture"], auto_move=True, move_fold="Data")
        self._floorSel.grid(row=0, columnspan=4)
        self._skySel = ImagePicker(parent, "Sky Texture:", default=self._entries["sky_texture"], auto_move=True, move_fold="Data")
        self._skySel.grid(row=1, columnspan=4)

        Label(parent, text="Wall Height:", width=10, anchor=W).grid(row=2, column=0, sticky=W)
        Label(parent, text="Edge Width:", width=10, anchor=W).grid(row=3, column=0, sticky=W)

        self._wallScale = Scale(parent, from_=10, to=1000, orient=HORIZONTAL)
        if self._entries["wall_height"] is not None:
            self._wallScale.set(self._entries["wall_height"])
        self._wallScale.grid(row=2, column=1, columnspan=2, sticky=W)

        self._edgeScale = Scale(parent, from_=10, to=1000, orient=HORIZONTAL)
        if self._entries["edge_width"] is not None:
            self._edgeScale.set(self._entries["edge_width"])
        self._edgeScale.grid(row=3, column=1, columnspan=2, sticky=W)

        Label(parent, text="Starting Node:", anchor=W).grid(row=4, column=0, sticky=W)
        self._start_node = Label(parent, text=self._entries["start_node"], anchor=W)
        self._start_node.grid(row=4, column=1, sticky=W)

    def populate(self, manager):

        self._entries["floor_texture"]  = manager.floor_texture
        self._entries["edge_width"]     = manager.edge_width
        self._entries["sky_texture"]    = manager.sky_texture
        self._entries["start_node"]     = manager.start_node
        self._entries["edge_width"]     = manager.edge_width
        self._entries["wall_height"]    = manager.wall_height

    def validate(self):
        (result, message) = DataValidator.validate(DataStore.EVENT.ENVIRONMENT_EDIT, {
            "floor_texture" : self._floorSel.get(),
            "sky_texture"   : self._skySel.get()
        })
        if result is not True:
            tkMessageBox.showerror("Input Error", message)
        return result

    def apply(self):
        self._entries["floor_texture"] = self._floorSel.get()
        self._entries["edge_width"] = self._edgeScale.get()
        self._entries["sky_texture"] = self._skySel.get()
        self._entries["wall_height"] = self._wallScale.get()
        self._manager.inform(DataStore.EVENT.ENVIRONMENT_EDIT, self._entries)

    def auto_populate(self):
        self._floorSel.set(Defaults.Environment.FLOOR_TEXTURE)
        self._skySel.set(Defaults.Environment.SKY_TEXTURE)
        self._wallScale.set(Defaults.Environment.WALL_HEIGHT)
        self._edgeScale.set(Defaults.Environment.EDGE_WIDTH)
        self._start_node.config(text=Defaults.Environment.START_NODE)
开发者ID:twisty-n,项目名称:MazeBuilder,代码行数:81,代码来源:DiaDoges.py

示例14: ObjectDialog

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import set [as 别名]
class ObjectDialog(Dialog):
    """
    A custom dialog that allows the user to configure placing objects in the virtual environment
    """
    def __init__(self, parent, x=None, y=None, populator=None):
        """
        Construct the instance of the object dialog

        :param parent:          The parent tk instance that spawns the dialog
        """
        self._entries = {
            "x_coordinate"   : None,
            "y_coordinate"   : None,
            "name"      : None,
            "mesh"      : None,
            "scale"     : None
        }
        self._scale_text = StringVar()
        self._scale_text.set(str(1))

        Dialog.__init__(self, parent, "ObjectBuilder", True, x, y, populator)

    def body(self, parent):
        """
        Define the custom body of the dialog
        :param parent:          The parent instance of the dialog
        """
        # Define the labels of all of the sub widgets that are to be used
        Label(parent, text="Name:").grid(row=0, column=0, sticky=W)
        Label(parent, text="X-Coord:").grid(row=1, column=0, sticky=W)
        Label(parent, text="Y-Coord:").grid(row=1, column=2, sticky=W)
        Label(parent, text="Mesh:").grid(row=2, column=0, sticky=W)
        Label(parent, text="Scale:").grid(row=3, column=0, sticky=W)
        Label(parent, textvariable=self._scale_text, bg="grey").grid(row=3, column=1, sticky=W)

        #Define the text entry widgets
        self._object_name = Label(parent, text=self._entries["name"])
        self._object_name.grid(column=1, row=0, sticky=W)
        self._x_coord = Label(parent, text=self._entries["x_coordinate"])
        self._x_coord.grid(column=1, row=1, sticky=W)
        self._y_coord = Label(parent, text=self._entries["y_coordinate"])
        self._y_coord.grid(column=3, row=1, stick=W)
        self._mesh = Entry(parent, width=15, text=self._entries["mesh"])
        if self._entries["mesh"] is None:
            self._mesh.insert(0, "No mesh loaded")
        else:
            self._mesh.insert(0, self._entries["mesh"])
        self._mesh.grid(column=1, row=2, columnspan=2, sticky=W)
        Button(parent, text="Load", width=5, command=self._load_mesh, default=ACTIVE).grid(column=3, row=2)

        self._scale = Scale(parent, from_=1, to=100, orient=HORIZONTAL, length=140, variable=self._scale_text, showvalue=0)
        if self._entries["scale"] is not None:
            self._scale.set(self._entries["scale"])
            self._scale_text.set(str(self._entries["scale"]))
        self._scale.grid(row=3, column=2, columnspan=2, sticky=W)

    def validate(self):
        (result, message) = DataValidator.validate(DataStore.EVENT.OBJECT_EDIT,
            {
                "name"  :   self._entries["name"],
                "mesh"  :   self._mesh.get()
            })
        if result is not True:
            tkMessageBox.showerror("Input Error", message)
        return result

    def apply(self):
        self._entries["scale"] = self._scale.get()
        self._entries["mesh"] = self._mesh.get()

    def _load_mesh(self):
        """
        Open a file dialog to load a mesh filepath
        :return:
        """
        Debug.printi("Load Mesh called", Debug.Level.INFO)
        types = \
            [
                ("DirectX", "*.x")
            ]
        dialog = tkFileDialog.Open(self, filetypes=types)
        file_path = dialog.show()

        file_path = self._move_img(file_path)

        self._mesh.delete(0, END)
        self._mesh.insert(0, str(file_path))
        Debug.printi("Mesh Filepath:" + file_path, Debug.Level.INFO)

    def _move_img(self, file_path):
        """
        Move the DirectX file to the Data folder automagically
        :param file_path:           The file path of the file to be moved
        :return:
        """
        try:
            src = file_path
            file_name = self._scrub_name(file_path)
            dest = os.path.dirname(os.path.realpath(__file__)) + "/" + file_name
            shutil.copy(src, dest)
#.........这里部分代码省略.........
开发者ID:twisty-n,项目名称:MazeBuilder,代码行数:103,代码来源:DiaDoges.py

示例15: __init__

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import set [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


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