Exemple #1
0
    def CreateWidgets(self):
        self.s1 = StringVar()
        self.s2 = StringVar()
        self.v1 = IntVar()
        self.v2 = IntVar()
        self.v3 = IntVar()
        self.v4 = IntVar()
        self.v5 = IntVar()

        self.lf1 = ttk.LabelFrame(self, text="Filename:")
        self.lf1.pack(fill=Tkconstants.BOTH)

        self.lf2 = ttk.LabelFrame(self,
                                  text="Processing choices: pick at least one")
        #       self.lf2.config(label="Processing choices: pick at least one")
        self.lf2.pack(fill=Tkconstants.BOTH)

        self.lf3 = ttk.LabelFrame(self, text="Logging")
        #       self.lf3.config(label="Logging")
        self.lf3.pack(fill=Tkconstants.BOTH)

        self.b1 = Button(self,
                         text="Run",
                         command=self.b1_callback,
                         default=Tkconstants.ACTIVE)
        self.b1.pack(side="bottom")

        self.e1 = Entry(self.lf1, textvariable=self.s1)
        self.e1.pack(fill=Tkconstants.BOTH)
        self.e1.bind("<Button-1>", self.e1_callback)

        self.e2 = Entry(self.lf3, textvariable=self.s2)
        self.e2.pack(fill=Tkconstants.BOTH)

        self.c1 = Checkbutton(self.lf2,
                              text="ET - generate Excel .csv output",
                              variable=self.v1)
        self.c1.pack(anchor=Tkconstants.W)

        self.c2 = Checkbutton(self.lf2,
                              text="HTML - include HTML output from et.py",
                              variable=self.v2)
        self.c2.pack(anchor=Tkconstants.W)

        self.c3 = Checkbutton(self.lf2,
                              text="KML - output for Google Earth",
                              variable=self.v3)
        self.c3.pack(anchor=Tkconstants.W)

        self.c4 = Checkbutton(self.lf2,
                              text="MR - generate a .gpx route file",
                              variable=self.v4)
        self.c4.pack(anchor=Tkconstants.W)

        self.c5 = Checkbutton(self.lf2,
                              text="ROOTER - generate a Rooter file",
                              variable=self.v5)
        self.c5.pack(anchor=Tkconstants.W)
Exemple #2
0
def sample_test():
    from Tix import Tk, Label, Button

    def test_cmd(event):
        if event.i == 0:
            return '%i, %i' % (event.r, event.c)
        else:
            return 'set'

    def browsecmd(event):
        print "event:", event.__dict__
        print "curselection:", test.curselection()
        print "active cell index:", test.index('active')
        print "active:", test.index('active', 'row')
        print "anchor:", test.index('anchor', 'row')

    root = Tk()

    var = ArrayVar(root)
    for y in range(-1, 4):
        for x in range(-1, 5):
            index = "%i,%i" % (y, x)
            var.set(index, index)

    label = Label(root, text="Proof-of-existence test for Tktable")
    label.pack(side = 'top', fill = 'x')
    
    quit = Button(root, text="QUIT", command=root.destroy)
    quit.pack(side = 'bottom', fill = 'x')

    test = Table(root,
                 rows=10,
                 cols=5,
                 state='disabled',
                 width=6,
                 height=6,
                 titlerows=1,
                 titlecols=1,
                 roworigin=-1,
                 colorigin=-1,
                 selectmode='browse',
                 selecttype='row',
                 rowstretch='unset',
                 colstretch='last',
                 browsecmd=browsecmd,
                 flashmode='on',
                 variable=var,
                 usecommand=0,
                 command=test_cmd)
    test.pack(expand=1, fill='both')
    test.tag_configure('sel', background = 'yellow')
    test.tag_configure('active', background = 'blue')
    test.tag_configure('title', anchor='w', bg='red', relief='sunken')
    root.mainloop()
Exemple #3
0
	def __init__(self,  parent, def_dict=None, tracker_path=None, to_game_callback=None, **kw):
		BaseWiget.__init__(self,parent, def_dict=def_dict, tracker_path=tracker_path, to_game_callback=to_game_callback, **kw)
		self.old_value = ""
		self._timer_clb_id = None
		self.entry = Entry(self, width = 100)
		self.entry.grid(row=1, column=1) 
		self.entry.bind("<Return>", self._onKeyEnter)
		self.entry.bind("<KeyRelease>", self._onKeyRelease)
		but = Button(self, text = "v", command = self._openDialog)
		but.grid(row=1, column=2)
		self.img_label = Tkinter.Label(self, text=" ")
		self.img_label.grid(row=1, column=3)


		self.old_value = self.getValue()
		self.onEndSetupContent()
Exemple #4
0
    def __init__(self,parent,variable=None,command=None,downcolor='red',**kw):

        self.oldcommand = command
        Button.__init__(self,parent,command=self.invoke,**kw)

        self._origbkg = self.cget('bg')
        self.downcolor = downcolor

        self._variable = variable
        if self._variable:
            self._variable.trace('w',self._varchanged)
            self._setstate(self._variable.get())
        else:
            self._setstate(0)

        self.bind("<Return>",self.invoke)
        self.bind("<1>",self.invoke)
        self.bind("<space>",self.invoke)
action_warn = lambda: showwarning(WARN, WARN + " pressed")
action_crit = lambda: showerror(CRIT, CRIT + " pressed")
action_regu = lambda: showinfo(REGU, REGU + " pressed")
action_INFO = lambda: showinfo(REGU,
                               "whatever you want,whatever you do,it works!")

top = Tk()
top.iconbitmap('App.ico')

# image = it.PhotoImage(file="GIF2.gif")
Button(top,
       text='chose one to see what may happened',
       command=action_INFO,
       compound='right',
       bg='green',
       fg='white',
       bitmap='info',
       padx=10,
       pady=10).pack()

builderButton = partial(Button, top)
WarnButton = partial(builderButton,
                     command=action_warn,
                     bg='green',
                     fg='white')
CritButton = partial(builderButton, command=action_crit, bg='red', fg='white')
ReguButton = partial(builderButton, command=action_regu, bg='grey', fg='white')

for (key, value) in SIGNS.iteritems():
    cmd = "{0}Button(text='{1}'{2}).pack(fill=X,expand=True)".format(
Exemple #6
0
class App(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master, relief=Tkconstants.RAISED)
        self.pack(fill=Tkconstants.BOTH)
        self.CreateWidgets()
        self.CreateMenubar()
        self.Initialize()

    def aboutMe(self):
        print "aboutMe"

    def CreateWidgets(self):
        self.s1 = StringVar()
        self.s2 = StringVar()
        self.v1 = IntVar()
        self.v2 = IntVar()
        self.v3 = IntVar()
        self.v4 = IntVar()
        self.v5 = IntVar()

        self.lf1 = ttk.LabelFrame(self, text="Filename:")
        self.lf1.pack(fill=Tkconstants.BOTH)

        self.lf2 = ttk.LabelFrame(self,
                                  text="Processing choices: pick at least one")
        #       self.lf2.config(label="Processing choices: pick at least one")
        self.lf2.pack(fill=Tkconstants.BOTH)

        self.lf3 = ttk.LabelFrame(self, text="Logging")
        #       self.lf3.config(label="Logging")
        self.lf3.pack(fill=Tkconstants.BOTH)

        self.b1 = Button(self,
                         text="Run",
                         command=self.b1_callback,
                         default=Tkconstants.ACTIVE)
        self.b1.pack(side="bottom")

        self.e1 = Entry(self.lf1, textvariable=self.s1)
        self.e1.pack(fill=Tkconstants.BOTH)
        self.e1.bind("<Button-1>", self.e1_callback)

        self.e2 = Entry(self.lf3, textvariable=self.s2)
        self.e2.pack(fill=Tkconstants.BOTH)

        self.c1 = Checkbutton(self.lf2,
                              text="ET - generate Excel .csv output",
                              variable=self.v1)
        self.c1.pack(anchor=Tkconstants.W)

        self.c2 = Checkbutton(self.lf2,
                              text="HTML - include HTML output from et.py",
                              variable=self.v2)
        self.c2.pack(anchor=Tkconstants.W)

        self.c3 = Checkbutton(self.lf2,
                              text="KML - output for Google Earth",
                              variable=self.v3)
        self.c3.pack(anchor=Tkconstants.W)

        self.c4 = Checkbutton(self.lf2,
                              text="MR - generate a .gpx route file",
                              variable=self.v4)
        self.c4.pack(anchor=Tkconstants.W)

        self.c5 = Checkbutton(self.lf2,
                              text="ROOTER - generate a Rooter file",
                              variable=self.v5)
        self.c5.pack(anchor=Tkconstants.W)

    def CreateMenubar(self):
        self.menubar = Menu(self)

        self.filemenu = Menu(self.menubar, tearoff=0)
        self.filemenu.add_command(label="Quit", command=self.quit)

        self.helpmenu = Menu(self.menubar, tearoff=0)
        self.helpmenu.add_command(label="About Me", command=self.aboutMe)

        self.menubar.add_cascade(label="File", menu=self.filemenu)
        self.menubar.add_cascade(label="Help", menu=self.helpmenu)


#       self.master.config(menu=self.menubar)

    def Initialize(self):
        self.s1.set("Filename goes here")
        self.s2.set("Logging")
        self.v1.set(1)
        self.v2.set(0)
        self.v3.set(1)
        self.v4.set(1)
        self.v5.set(1)

    def b1_callback(self):
        print '"%s"' % self.e1.get(), \
            self.v1.get(), \
            self.v2.get(), \
            self.v3.get(), \
            self.v4.get(), \
            self.v5.get()

        if self.s1.get() == "Filename goes here":
            self.e1_callback(None)
            return
        else:
            print "Process %s" % self.s1.get()

    def e1_callback(self, event):
        print "e1_callback", "%s" % event
        import tkFileDialog
        filename = tkFileDialog.askopenfilename()
        if filename:
            self.s1.set(filename)