Ejemplo n.º 1
0
class Gui(object):
    """ Gui for stopwatch """
    def __init__(self, stopwatch):
        """ init stopwatch gui
            stopwatch:Stopwatch -> """
        self.win = Window()  # make window an attribute
        self.stopw = stopwatch  # make stopwatch an attribute
        self.makeGui()  # create gui

    def makeGui(self):
        """ create the Gui """
        self.win.setTitle('Stopwatch v1.0')
        self.win.addStyle(
            'r.TLabel',
            foreground='red',  # create the styles
            font=('Helvetica', '30'))
        self.win.addStyle('g.TLabel',
                          foreground='green',
                          font=('Helvetica', '30'))
        self.win.addLabel('elapsed', 'Elapsed Time', style='r.TLabel')
        buttons = [('Start', self.startstop), ('Reset', self.reset),
                   ('Exit', self.win.cancel)]  # label and assign buttons
        self.win.addButton('buttons', cmd=buttons)  # create buttons
        self.win.plot('elapsed', row=0)
        self.win.plot('buttons', row=1, pady=10)
        self.update()  # update display

    def startstop(self):
        """ start or stop the stopwatch """
        if self.stopw.running:
            self.stopw.stop()
            self.win.changeWidget('buttons', 0, text='Start')  # relabel button
            self.win.changeWidget('elapsed', style='r.TLabel')  # color display
            self.win.changeState('buttons', 1, ['!disabled'])  # enable Reset
        else:
            self.stopw.start()
            self.win.changeWidget('buttons', 0, text='Stop')  # relabel button
            self.win.changeWidget('elapsed', style='g.TLabel')  # color display
            self.win.changeState('buttons', 1, ['disabled'])  # disable Reset

    def reset(self):
        """ reset stopwatch """
        self.stopw.reset()  # reset it

    def update(self):
        """ update display """
        etime = self.stopw.check()  # get elapsed time
        template = '{:02}:{:02}:{:02}.{:02}'  # 2 digits leading zero
        stime = template.format(*etime)  # format as hh:mm:ss.cc
        self.win.set('elapsed', stime)  # update display
        self.win.master.after(10, self.update)  # call again after .01 sec
Ejemplo n.º 2
0
""" Some initial comments here at the top
of the screen. This just shows how we can
comment multiline"""

from tkintertoy import Window
bob = ''
bob2 = ''
bob3 = ''
categories = ['Car', 'Bike', 'Bus']
gui = Window()
gui.setTitle('My First Tkintertoy GUI!')
gui.addEntry('name', 'Type in your name')
gui.addLabel('welcome', 'Welcome message *** TEST ***')
gui.addEntry('Age', 'Type in your age')
gui.addLabel('old', 'You are of age')
gui.addButton('commands')
gui.addRadio('')
gui.addRadio('category', 'Item Types', categories)
gui.plot('name', row=0)
gui.plot('Age', row=1)
gui.plot('welcome', row=2)
gui.plot('old', row=3)
gui.plot('category', row=4)
gui.plot('commands', row=5, pady=10)
while True:
    gui.waitforUser()
    if gui.content:
        gui.set('welcome', 'Welcome ' + gui.get('name'))
        bob = gui.get('name')
        gui.set('old', gui.get('Age'))
        bob2 = gui.get('Age')
Ejemplo n.º 3
0
from tkintertoy import Window
gui = Window()
gui.setTitle('My First Tkintertoy GUI!')
gui.addEntry('name', 'Type in your name')
gui.addLabel('welcome', 'Welcome message')
gui.addButton('commands')
gui.plot('name', row=0)
gui.plot('welcome', row=1)
gui.plot('commands', row=2, pady=10)
while True:
    gui.waitforUser()
    if gui.content:
        gui.set('welcome', 'Welcome ' + gui.get('name'))
    else:
        break
Ejemplo n.º 4
0
from tkintertoy import Window
import smtplib
import email

#Connect to server
server = smtplib.SMTP('smtp.outlook.com:587')
server.starttls()

#Set up GUI
gui = Window()
gui.setTitle('Pick two ports for your NP class!')
gui.addEntry('stu_no', 'Type in your student number',width=35)
gui.addEntry('pass', 'Type in your student account\'s password',width=35, show="*")
gui.addEntry('port_1', 'Pick port 1',width=35)
gui.addEntry('port_2', 'Pick port 2',width=35)
gui.addLabel('message', '',width=35, effects='bold', padding=5, foreground='red')
gui.addButton('commands')
gui.plot('stu_no', row=0, pady=10)
gui.plot('pass', row=1, pady=10)
gui.plot('port_1', row=2, pady=10)
gui.plot('port_2', row=3, pady=10)
gui.plot('message', row=4, pady=10)
gui.plot('commands', row=5, pady=10)

#spreadsheet information
SPREADSHEET_ID = "1mn93Hl0zT7Cb2YaPryj523IQEzelVa1HWLrR3ZxrJRU" # <Your spreadsheet ID>
RANGE_NAME = "data" # <Your worksheet name>

#setup google spreadsheet
gc = pygsheets.authorize(service_file='creds.json')
sh = gc.open_by_key(SPREADSHEET_ID)