예제 #1
0
def _calltip_window(parent):  # htest #
    from Tkinter import Toplevel, Text, LEFT, BOTH

    top = Toplevel(parent)
    top.title("Test calltips")
    top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200,
                  parent.winfo_rooty() + 150))
    text = Text(top)
    text.pack(side=LEFT, fill=BOTH, expand=1)
    text.insert("insert", "string.split")
    top.update()
    calltip = CallTip(text)

    def calltip_show(event):
        calltip.showtip("(s=Hello world)", "insert", "end")
    def calltip_hide(event):
        calltip.hidetip()
    text.event_add("<<calltip-show>>", "(")
    text.event_add("<<calltip-hide>>", ")")
    # - 2016 9 28 --
    text.event_add('<<calltip-show>>', '<less>')
    text.event_add('<<calltip-hide>>', '<greater>')
    # ---
    text.bind("<<calltip-show>>", calltip_show)
    text.bind("<<calltip-hide>>", calltip_hide)
    text.focus_set()
예제 #2
0
def _calltip_window(parent):  # htest #
    from Tkinter import Toplevel, Text, LEFT, BOTH

    top = Toplevel(parent)
    top.title("Test calltips")
    top.geometry("200x100+%d+%d" %
                 (parent.winfo_rootx() + 200, parent.winfo_rooty() + 150))
    text = Text(top)
    text.pack(side=LEFT, fill=BOTH, expand=1)
    text.insert("insert", "string.split")
    top.update()
    calltip = CallTip(text)

    def calltip_show(event):
        calltip.showtip("(s=Hello world)", "insert", "end")

    def calltip_hide(event):
        calltip.hidetip()

    text.event_add("<<calltip-show>>", "(")
    text.event_add("<<calltip-hide>>", ")")
    # - 2016 9 28 --
    text.event_add('<<calltip-show>>', '<less>')
    text.event_add('<<calltip-hide>>', '<greater>')
    # ---
    text.bind("<<calltip-show>>", calltip_show)
    text.bind("<<calltip-hide>>", calltip_hide)
    text.focus_set()
예제 #3
0
class SplashScreen:

    root = None
    win = None
    img = 'images/splash-screen'
    flag = 0

    def __init__(self, root):
        self.root = root
        self.width = 500
        self.height = 300
        self.flag = config.preferences.show_splash

    def show(self):
        self.root.withdraw()
        if self.flag:
            img_file = os.path.join(app.config.sk_share_dir, self.img + '.png')
            from sk1sdk.tkpng import load_icon
            load_icon(self.root, img_file, self.img)

            scrnWt = self.root.winfo_screenwidth()
            scrnHt = self.root.winfo_screenheight()
            winXPos = (scrnWt / 2) - (self.width / 2)
            winYPos = (scrnHt / 2) - (self.height / 2)

            self.win = Toplevel()
            self.win.overrideredirect(1)
            self.win.configure(background='black')
            self.banner = Label(self.win,
                                image=self.img,
                                cursor='watch',
                                borderwidth=0)
            self.banner.pack()

            self.verlb = Label(self.win,
                               text='version %s' % (config.version, ),
                               bg='white')
            self.verlb.place(x=10, y=240)
            self.verlb['font'] += ' bold'

            self.txtlb = Label(self.win, text='Start...', bg='white')
            self.txtlb.place(x=10, y=265)
            self.progress_bar = SS_ProgressBar(self.win)
            self.progress_bar.pack(fill=X, side=TOP)
            geom = (self.width, self.height, winXPos, winYPos)
            self.win.geometry('%dx%d+%d+%d' % geom)
            self.win.update()

    def hide(self):
        if self.flag and self.win:
            self.win.withdraw()
            self.win.destroy()

    def set_val(self, val, txt=''):
        self.progress_bar.set_val(val)
        if txt: self.txtlb['text'] = txt
        self.win.update()
예제 #4
0
class SshUserPw(object):
    '''
    A separate GUI window to enter the SSH username and password
    '''
    def __init__(self, callback):
        self._callback = callback

        self._root = Toplevel()
        self._root.title('FlowEntry Trace')
        self._root.minsize(width=300, height=150)

        self._top_frame = Frame(self._root)
        self._top_frame.pack(side=TOP, fill=X, padx=10, pady=10)

        # The text labels
        label_entry_frame = Frame(self._top_frame)
        label_entry_frame.pack(side=TOP, anchor=W, pady=5)
        self._username_label = LabelEntry(label_entry_frame, 'username')
        self._password_label = LabelEntry(label_entry_frame, 'password')

        # the buttons
        button_frame = Frame(self._top_frame, pady=5)
        button_frame.pack(side=BOTTOM, anchor=S)
        buttons_dict = OrderedDict([('ok', self._ok_callback),
                                    ('cancel', self._cancel_callback)])
        Buttons(button_frame, buttons_dict, button_orientation=LEFT)

        # Hide this window until its needed
        self._root.withdraw()

    @property
    def username(self):
        return self._username_label.entry_text

    @property
    def password(self):
        return self._password_label.entry_text

    def display(self, show=True):
        if show:
            self._root.update()
            self._root.deiconify()
        else:
            self._root.withdraw()

    def _cancel_callback(self):
        self.display(False)

    def _ok_callback(self):
        if not self.username or not self.password:
            Popup('Both the username and password must be filled in')
            return

        self.display(False)
        self._callback()
예제 #5
0
파일: skapp.py 프로젝트: kindlychung/sk1
class SplashScreen:

	root = None
	win = None
	img = 'images/splash-screen'
	flag = 0

	def __init__(self, root):
		self.root = root
		self.width = 500
		self.height = 300
		self.flag = config.preferences.show_splash

	def show(self):
		self.root.withdraw()
		if self.flag:
			img_file = os.path.join(app.config.sk_share_dir, self.img + '.png')
			from sk1sdk.tkpng import load_icon
			load_icon(self.root, img_file, self.img)

			scrnWt = self.root.winfo_screenwidth()
			scrnHt = self.root.winfo_screenheight()
			winXPos = (scrnWt / 2) - (self.width / 2)
			winYPos = (scrnHt / 2) - (self.height / 2)

			self.win = Toplevel()
			self.win.overrideredirect(1)
			self.win.configure(background='black')
			self.banner = Label(self.win, image=self.img, cursor='watch',
							borderwidth=0)
			self.banner.pack()

			self.verlb = Label(self.win, text='version %s' % (config.version,),
							bg='white')
			self.verlb.place(x=10, y=240)
			self.verlb['font'] += ' bold'

			self.txtlb = Label(self.win, text='Start...',
							bg='white')
			self.txtlb.place(x=10, y=265)
			self.progress_bar = SS_ProgressBar(self.win)
			self.progress_bar.pack(fill=X, side=TOP)
			geom = (self.width, self.height, winXPos, winYPos)
			self.win.geometry('%dx%d+%d+%d' % geom)
			self.win.update()

	def hide(self):
		if self.flag and self.win:
			self.win.withdraw()
			self.win.destroy()

	def set_val(self, val, txt=''):
		self.progress_bar.set_val(val)
		if txt: self.txtlb['text'] = txt
		self.win.update()
예제 #6
0
def make_error_dialog(player_dlg):
    error_dlg = Toplevel(master=player_dlg);
    error_dlg.title( "Error" );
    error_dlg.grab_set();
    error_msg = Message(error_dlg, aspect=300, text="Player count must be between %d and %d" % (MIN_PLAYER_COUNT, MAX_PLAYER_COUNT) )
    error_msg.pack();
    error_button = Button(error_dlg, text="OK", \
                            command=error_dlg.destroy);
    error_button.pack();
    error_dlg.update();
    return
예제 #7
0
 def __init__(self, master, resultObj, backgroundImg, safetyTimeout,
              frameClass, *frameClassParams, **frameClassNamedParams):
     SysmodalBase.__init__(self, master, backgroundImg, safetyTimeout)
     childWindow = Toplevel(self)
     childWindow.attributes("-topmost", True)
     resultObj.result = frameClass(childWindow, *frameClassParams,
                                   **frameClassNamedParams)
     sw = master.winfo_screenwidth()
     sh = master.winfo_screenheight()
     childWindow.update()
     w = childWindow.winfo_reqwidth()
     h = childWindow.winfo_reqheight()
     childWindow.geometry('%dx%d+%d+%d' %
                          (w, h, sw / 2 - w / 2, sh / 2 - h / 2))
     self._playUACSound()
예제 #8
0
 def loginCommand(self, username, password):
     if self.gui.btd.database.login(username, password):
         self.gui.screenChange(welcomePage(self.root, self.gui))
     else:
         popup = Toplevel()
         popup.title("Incorrect")
         
         windowWidth = popup.winfo_screenwidth()
         windowHeight = popup.winfo_screenheight()
         
         width = .25 * windowWidth
         height = .1 * windowHeight
         x = (windowWidth - width) / 2
         y = (windowHeight - height) / 2
         
         popup.geometry("%dx%d+%d+%d" % (width, height, x, y))
         popup.update()
         
         Label(popup, text="Incorrect username or password!").pack()
         Button(popup, text="Dismiss", command=popup.destroy).pack()
예제 #9
0
    def createUser(self, username, password, fname, lname):
        if self.gui.btd.database.newUser(username, password, fname, lname):
            popup = Toplevel()
            popup.title("Account created!")

            windowWidth = popup.winfo_screenwidth()
            windowHeight = popup.winfo_screenheight()

            width = .25 * windowWidth
            height = .1 * windowHeight
            x = (windowWidth - width) / 2
            y = (windowHeight - height) / 2

            popup.geometry("%dx%d+%d+%d" % (width, height, x, y))
            popup.update()

            Label(
                popup,
                text="Your new account has been successfully created!").pack()
            Button(popup, text="Dismiss", command=popup.destroy).pack()

            self.gui.screenChange(title.titlePage(self.root, self.gui))
        else:
            popup = Toplevel()
            popup.title("Username Exists!")

            windowWidth = popup.winfo_screenwidth()
            windowHeight = popup.winfo_screenheight()

            width = .25 * windowWidth
            height = .1 * windowHeight
            x = (windowWidth - width) / 2
            y = (windowHeight - height) / 2

            popup.geometry("%dx%d+%d+%d" % (width, height, x, y))
            popup.update()

            Label(popup,
                  text="A user account with that username already exists!"
                  ).pack()
            Button(popup, text="Dismiss", command=popup.destroy).pack()
예제 #10
0
    def update(self):
        Toplevel.update(self)

        rootx = self.area.winfo_rootx()
        rooty = self.area.winfo_rooty()
        self.start_index = self.area.index('insert')
        x, y, width, height = self.area.bbox('insert')
        info = self.area.dlineinfo('insert')
        line_x = info[0]
        line_y = info[1]
        line_width = info[2]
        line_height = info[3]
        baseline = info[4]
        win_height = self.winfo_height()
        area_height = self.area.winfo_height()
        win_width = self.winfo_width()
        area_width = self.area.winfo_width()
        vpos = self.calculate_vertical_position(y, rooty, line_height,
                                                win_height, area_height)
        hpos = self.calculate_horizontal_position(x, rootx, win_width,
                                                  area_width)

        self.wm_geometry("+%d+%d" % (hpos, vpos))
예제 #11
0
 def createUser(self, username, password, fname, lname):
     if self.gui.btd.database.newUser(username, password, fname, lname):
         popup = Toplevel()
         popup.title("Account created!")
         
         windowWidth = popup.winfo_screenwidth()
         windowHeight = popup.winfo_screenheight()
         
         width = .25 * windowWidth
         height = .1 * windowHeight
         x = (windowWidth - width) / 2
         y = (windowHeight - height) / 2
         
         popup.geometry("%dx%d+%d+%d" % (width, height, x, y))
         popup.update()
         
         Label(popup, text="Your new account has been successfully created!").pack()
         Button(popup, text="Dismiss", command=popup.destroy).pack()
         
         self.gui.screenChange(title.titlePage(self.root, self.gui))
     else:
         popup = Toplevel()
         popup.title("Username Exists!")
         
         windowWidth = popup.winfo_screenwidth()
         windowHeight = popup.winfo_screenheight()
         
         width = .25 * windowWidth
         height = .1 * windowHeight
         x = (windowWidth - width) / 2
         y = (windowHeight - height) / 2
         
         popup.geometry("%dx%d+%d+%d" % (width, height, x, y))
         popup.update()
         
         Label(popup, text="A user account with that username already exists!").pack()
         Button(popup, text="Dismiss", command=popup.destroy).pack()
예제 #12
0
class Tooltips:
    tooltip_delay = 100

    def __init__(self):
        self.descriptions = {}
        self.balloon = None
        self.balloon_label = None
        self.last_widget = ''
        self.after_id = None
        self.root = None

    def AddDescription(self, widget, description):
        self.descriptions[widget._w] = description
        if widget._w == self.last_widget:
            self.balloon_label['text'] = description

    def RemoveDescription(self, widget):
        if type(widget) == InstanceType:
            widget = widget._w
        if self.descriptions.has_key(widget):
            del self.descriptions[widget]

    def GetDescription(self, widget):
        if type(widget) == InstanceType:
            widget = widget._w
        if self.descriptions.has_key(widget):
            return self.descriptions[widget]
        return ''

    def create_balloon(self, root):
        self.root = root
        self.balloon = Toplevel(self.root)
        self.balloon.withdraw()
        self.balloon.overrideredirect(1)
        self.balloon["relief"] = 'flat'
        label = TLabel(self.balloon, text='Tooltip', style='Tooltips')
        label.pack(ipadx=2, ipady=2)
        self.balloon_label = label

    def popup_balloon(self, widget_name, x, y, text):
        self.last_widget = widget_name
        self.balloon.withdraw()
        self.balloon_label['text'] = text

        width = self.balloon_label.winfo_reqwidth()
        height = self.balloon_label.winfo_reqheight()

        screenwidth = self.root.winfo_screenwidth()
        screenheight = self.root.winfo_screenheight()

        x = self.root.winfo_pointerx()
        y = self.root.winfo_pointery() + 20

        if screenwidth < (x + width):
            x = x - width

        if screenheight < (y + height):
            y = y - height - 25

        self.balloon.geometry('%+d%+d' % (x, y))
        self.balloon.update()
        self.balloon.deiconify()
        self.balloon.tkraise()

    def popup_delayed(self, widget_name, x, y, text, *args):
        self.after_id = None
        self.popup_balloon(widget_name, x, y, text)

    def enter_widget(self, event):
        widget_name = event.widget
        text = self.GetDescription(widget_name)
        if text:
            x = event.x
            y = event.y
            if self.after_id:
                print 'after_id in enter'
                self.root.after_cancel(self.after_id)
            self.after_id = self.root.after(self.tooltip_delay,
                                            self.popup_delayed, widget_name, x,
                                            y, text)

    def leave_widget(self, event):
        global last_widget, after_id
        if self.after_id is not None:
            self.root.after_cancel(self.after_id)
            self.after_id = None
            self.last_widget = ''
        last_widget = ''
        self.balloon.withdraw()

    button_press = leave_widget

    def destroy_widget(self, event):
        self.RemoveDescription(event.widget)
예제 #13
0
def inicio(c):
    global ventana2, Labeli, Labelt, img0, img1, imgF, row, cont
    instruction = None
    img0 = PhotoImage(file="00.gif")  # Reads photos
    img00 = PhotoImage(file="0000.gif")
    imgF = PhotoImage(file="FF.gif")

    if c:
        ventana2 = Toplevel(ventana)
        ventana2.title("MANITOR")
        ventana2.configure(bg="white")
        ventana2.geometry("1000x600+5+40")

        Labelt = Label(
            ventana2,
            text='BIENVENIDO ',  # ventana2 TEXTO
            fg="black",
            bg="white",
            font=("Helvetica 36 "))
        ventana2.columnconfigure(0, weight=1)
        Labelt.grid(row=1, column=0)
        Labeli = Label(ventana2, image=img00)  # ventana2 IMAGEN
        Labeli.grid(row=2, column=0)

    else:
        Labelt.config(text='BIENVENIDO ')
        Labeli.image = img00
        Labeli.config(image=img00)
    ventana.iconify()  # Turns window into an icon

    row = row + 1
    cont = cont + 1
    while 1:

        queue = Queue()
        Labelt.config(text='BIENVENIDO \n  Por favor moje sus manos con agua')
        worksheet.write_datetime(row, col, date_time, f2)
        worksheet.write_datetime(row, col + 1, date_time, f3)
        worksheet.write(row, col + 2, cont, f6)
        worksheet.write(row, col + 3, 'NUEVA PERSONA', f4)
        ventana2.update()
        video000()

        def jabon():
            def cero(q):
                analysisRegion = 1
                print regionCoord
                tipoMovimiento = BByOFfile.BByOF(2, lower, upper, regionCoord,
                                                 analysisRegion, 10)
                q.put([tipoMovimiento])

            Labelt.config(text='Deposite jabón en la mano')
            global row
            row = row + 1
            worksheet.write(row, col + 3, 'jabon', f5)
            ventana2.update()
            c = threading.Thread(target=cero, args=(queue, ))
            c.start()
            video00()

            if c.isAlive():
                c.join()
            instruction = queue.get()
            instruction = falseType(instruction[0], Labelt, Labeli, img0, imgF)
            if not instruction:
                jabon()

        jabon()

        ######################## instruccion 1

        def primero1():
            def primero(q):
                analysisRegion = 2
                tipoMovimiento = BByOFfile.BByOF(2, lower, upper, regionCoord,
                                                 analysisRegion, 10)
                q.put([tipoMovimiento])

            p = Thread(target=primero, args=(queue, ))
            p.start()
            Labelt.config(text='Frote las palmas de las manos \n entre sí')
            global row
            row = row + 1
            worksheet.write(row, col + 3, 'instruccion1', f5)
            ventana2.update()
            ventana2.update()
            video1()

            if p.isAlive():
                p.join()
            instruction = queue.get()
            instruction = falseType(instruction[0], Labelt, Labeli, img0, imgF)
            if not instruction:
                primero1()

        primero1()

        ########################## instruccion2

        ##        def segundo(q):
        ##            analysisRegion = 2
        ##            tipoMovimiento=BByOFfileO.BByOF(2,lower,upper,regionCoord,analysisRegion,10)
        ##            q.put([tipoMovimento])
        ##
        ##        s=Thread(target=segundo, args=(queue,))
        ##        s.start()
        ##        Labelt.config(text='Frote la palma de la mano derecha \n contra el dorso de la mano izquierda  \n entrelazando los dedos y viceversa')
        ##        ventana2.update()
        ##        video2()
        ##
        ##        if s.isAlive():
        ##            s.join()
        ##        instruction=queue.get()
        ##        instruction=falseType(instruction[0],Labelt,Labeli,img0,imgF)
        ##        if not instruction:
        ##            inicio(0)

        ######################## fin instrucciones

        Labeli = Label(ventana2, image=img00)
        Labeli.grid(row=2, column=0)
        Labelt.config(text='Sus manos son seguras')
        row = row + 1
        worksheet.write_datetime(row, col, date_time, f2)
        worksheet.write_datetime(row, col + 1, date_time, f3)
        worksheet.write(row, col + 3, 'TERMINO')
        ventana2.update()
        ventana2.after(2000)
예제 #14
0
파일: tooltips.py 프로젝트: kindlychung/sk1
class Tooltips:
	tooltip_delay = 100

	def __init__(self):
		self.descriptions = {}
		self.balloon = None
		self.balloon_label = None
		self.last_widget = ''
		self.after_id = None
		self.root = None

	def AddDescription(self, widget, description):
		self.descriptions[widget._w] = description
		if widget._w == self.last_widget:
			self.balloon_label['text'] = description

	def RemoveDescription(self, widget):
		if type(widget) == InstanceType:
			widget = widget._w
		if self.descriptions.has_key(widget):
			del self.descriptions[widget]

	def GetDescription(self, widget):
		if type(widget) == InstanceType:
			widget = widget._w
		if self.descriptions.has_key(widget):
			return self.descriptions[widget]
		return ''


	def create_balloon(self, root):
		self.root = root
		self.balloon = Toplevel(self.root)
		self.balloon.withdraw()
		self.balloon.overrideredirect(1)
		self.balloon["relief"] = 'flat'
		label = TLabel(self.balloon, text='Tooltip', style='Tooltips')
		label.pack(ipadx=2, ipady=2)
		self.balloon_label = label


	def popup_balloon(self, widget_name, x, y, text):
		self.last_widget = widget_name
		self.balloon.withdraw()
		self.balloon_label['text'] = text

		width = self.balloon_label.winfo_reqwidth()
		height = self.balloon_label.winfo_reqheight()

		screenwidth = self.root.winfo_screenwidth()
		screenheight = self.root.winfo_screenheight()

		x = self.root.winfo_pointerx()
		y = self.root.winfo_pointery() + 20

		if screenwidth < (x + width):
			x = x - width

		if screenheight < (y + height):
			y = y - height - 25

		self.balloon.geometry('%+d%+d' % (x, y))
		self.balloon.update()
		self.balloon.deiconify()
		self.balloon.tkraise()

	def popup_delayed(self, widget_name, x, y, text, *args):
		self.after_id = None
		self.popup_balloon(widget_name, x, y, text)

	def enter_widget(self, event):
		widget_name = event.widget
		text = self.GetDescription(widget_name)
		if text:
			x = event.x;y = event.y
			if self.after_id:
				print 'after_id in enter'
				self.root.after_cancel(self.after_id)
			self.after_id = self.root.after(self.tooltip_delay, self.popup_delayed, widget_name, x, y, text)

	def leave_widget(self, event):
		global last_widget, after_id
		if self.after_id is not None:
			self.root.after_cancel(self.after_id)
			self.after_id = None
			self.last_widget = ''
		last_widget = ''
		self.balloon.withdraw()

	button_press = leave_widget


	def destroy_widget(self, event):
		self.RemoveDescription(event.widget)
예제 #15
0
class Tooltips:

    def __init__(self):
	self.descriptions = {}
	self.balloon = None
	self.balloon_label = None
	self.last_widget = ''
	self.after_id = None

    def AddDescription(self, widget, description):
	self.descriptions[widget._w] = description
	if widget._w == self.last_widget:
	    self.balloon_label['text'] = description

    def RemoveDescription(self, widget):
	if type(widget) == InstanceType:
	    widget = widget._w
	if self.descriptions.has_key(widget):
	    del self.descriptions[widget]

    def GetDescription(self, widget):
	if type(widget) == InstanceType:
	    widget = widget._w
	if self.descriptions.has_key(widget):
	    return self.descriptions[widget]
	return ''


    def create_balloon(self, root):
	self.root = root
	self.balloon = Toplevel(self.root, name = 'tooltips')
	self.balloon.withdraw()
	self.balloon.overrideredirect(1)
	label = Label(self.balloon, name = 'label', text = 'Tooltip')
	label.pack()
	self.balloon_label = label


    def popup_balloon(self, widget_name, x, y, text):
	self.last_widget = widget_name
	self.balloon.withdraw()
	self.balloon_label['text'] = text
	x = x - self.balloon_label.winfo_reqwidth() / 2
	self.balloon.geometry('%+d%+d' % (x, y))
	self.balloon.update()
	self.balloon.deiconify()
	self.balloon.tkraise()

    def popup_delayed(self, widget_name, x, y, text, *args):
	self.after_id = None
	self.popup_balloon(widget_name, x, y, text)

    def enter_widget(self, widget_name):
	text = self.GetDescription(widget_name)
	if text:
	    widget = self.root.nametowidget(widget_name)
	    x = widget.winfo_rootx() + widget.winfo_width() / 2
	    y = widget.winfo_rooty() + widget.winfo_height()
	    #y = y + height
	    #x = x + width / 2
	    if self.after_id:
		print 'after_id in enter'
		self.root.after_cancel(self.after_id)
	    self.after_id = self.root.after(config.preferences.tooltip_delay,
					    self.popup_delayed,
					    widget_name, x, y, text)

    def leave_widget(self, widget_name):
	global last_widget, after_id
	if self.after_id is not None:
	    self.root.after_cancel(self.after_id)
	    self.after_id = None
	    self.last_widget = ''
	last_widget = ''
	self.balloon.withdraw()

    button_press = leave_widget


    def destroy_widget(self, event):
	self.RemoveDescription(event.widget)
예제 #16
0
 def do_a_turn(self):
     # roll die
     die1_val = random.randint(1,6)
     die2_val = random.randint(1,6)
     # TODO: potentially simulate die motion like in matlab version
     # change die values on screen
     self.dice1_strvar.set(str(die1_val))
     self.dice2_strvar.set(str(die2_val))
     
     # check dice conditions
     ethan_val = int(self.ethan_strvar.get())
     player_val = int(self.player_strvars[self.player_turn].get())
     if (die1_val+die2_val == 4):
         # player gets ethan's stuff
         player_val = player_val + ethan_val
         ethan_val = 0
     elif (die1_val+die2_val == 2) and self.ethan_eyes:
         # player loses it all to ethan
         ethan_val = player_val + ethan_val
         player_val = 0
     else:
         # player loses one chip to ethan
         ethan_val = ethan_val + 1
         player_val = player_val - 1
     self.ethan_strvar.set(str(ethan_val))
     self.player_strvars[self.player_turn].set(str(player_val))
     # check for the lose condition
     total_chips = 0
     num_players_positive = 0
     for x in self.player_strvars:
         if int(x.get()) > 0:
             num_players_positive = num_players_positive + 1
         total_chips = total_chips + int(x.get())
     if total_chips == 0:
         # everybody loses
         error_dlg = Toplevel(master=self.main_window)
         error_dlg.geometry("%dx%d+%d+%d" % 
             (INIT_WINDOW_WIDTH, INIT_WINDOW_HEIGHT, X_POS, Y_POS))
         error_dlg.title( "LOSERS" );
         error_dlg.grab_set();
         error_msg = Message(error_dlg, aspect=300, text="EVERYBODY LOSES, AE2015")
         error_msg.pack();
         error_button = Button(error_dlg, text="OK", \
                             command=lambda: self.destroy_all(error_dlg));
         error_button.pack();
         error_dlg.update();
     elif (num_players_positive == 1) and (player_val > ethan_val):
         #win condition, only for player who just moved
         player_name = self.player_name_list[self.player_turn].get();
         error_dlg = Toplevel(master=self.main_window)
         error_dlg.geometry("%dx%d+%d+%d" % 
             (INIT_WINDOW_WIDTH, INIT_WINDOW_HEIGHT, X_POS, Y_POS))
         error_dlg.title( "WINNER" );
         error_dlg.grab_set();
         error_msg = Message(error_dlg, aspect=300, text="GOOD JOB %s, YOU BEAT ETHAN" % (player_name) )
         error_msg.pack();
         error_button = Button(error_dlg, text="OK", \
                                 command=error_dlg.destroy);
         error_button.pack();
         error_dlg.update();
     else:
         # game isn't over, increment turn to next positive player
         self.player_frame_list[self.player_turn].config(relief='flat', \
             borderwidth=0)
         num_players = len(self.player_strvars)
         found_next = 0
         self.current_turn = self.current_turn + 1
         while (found_next == 0):
             self.player_turn = (self.player_turn + 1) % num_players
             if int(self.player_strvars[self.player_turn].get()) > 0:
                 found_next = 1
         self.player_frame_list[self.player_turn].config(relief='raised', \
             borderwidth=2)    
     return
예제 #17
0
def inicio(c):
    global ventana2, Labeli, Labelt, panel
    global img0, img1, imgF
    img0=PhotoImage(file="00.gif") # Reads photos
    img1=PhotoImage(file="11.gif")
    imgF=PhotoImage(file="FF.gif")
    
    if c:  
        ventana2=Toplevel(ventana)
        ventana2.title("MANITOR")
        ventana2.configure(bg="white")
        ventana2.geometry("1000x600+5+40")
    
        Labelt=Label(ventana2,text='BIENVENIDO ', # ventana2 TEXTO
                fg="black",bg="white",font=("Helvetica 36 "))
        ventana2.columnconfigure(0,weight=1)
        Labelt.grid(row=1,column=0)
        
        Labeli=Label(ventana2,image=img1) # ventana2 IMAGEN
        ventana2.columnconfigure(0,weight=1)
        ventana2.update()
        Labeli.grid(row=2,column=0)
        
    else:#Toda esta parte no es necesaria se podria borrar hasta el update, ya que es un estado inical que nunca se muestra igual que arriba
        Labelt.config(text='BIENVENIDO ')
        ventana2.update()
        Labeli=Label(ventana2,image=img1)
        ventana2.columnconfigure(0,weight=1)
        Labeli.grid(row=2,column=0)
        Labeli.config(image=img1)
        Labeli.image=img1
        ventana2.update()
    ventana.iconify() # Turns window into an icon

    while 1:

##        cur.execute("INSERT INTO manitor VALUES(nextval('usuario_sequence'), current_timestamp, ' inicio ')")
        Labeli.destroy()
        ventana2.update()
        Labelt.config(text='BIENVENIDO \n  Por favor moje sus manos con agua')
        ventana2.update()
        video000                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ()
        ventana2.update()
        
        Labelt.config(text='Deposite jabón en la mano')
##        cur.execute("INSERT INTO manitor VALUES(nextval('usuario_sequence'), current_timestamp, ' nuevo usuario ')")
        ventana2.update()

        def cero():
            b,auxType = contadorMovimiento.funcionMovimientoEnRegion(y[1],3,2,lower,upper) 
            instruction = falseType(b,auxType,Labelt,Labeli,img0,imgF)
            if not instruction:
                inicio(0)
                
        Thread(target=cero).start()
        Thread(target=video00()).start()

######################## instruccion 1
        
        Labeli.destroy()
        Labelt.config(text='Frote las palmas de las manos \n entre sí')
        ventana2.update()

        def primero():
            d,auxType = contadorMovimiento.funcionMovimientoEnRegion(y[1],3,2,lower,upper) 
            instruction = falseType(d,auxType,Labelt,Labeli,img0,imgF)
            if not instruction:
                inicio(0)
                
        Thread(target=primero).start()
        Thread(target=video1()).start()

########################## instruccion2
##
##        Labeli.destroy()
##        Labelt.config(text='Frote la palma de la mano derecha \n contra el dorso de la mano izquierda  \n entrelazando los dedos y viceversa')
##        panel = Label(ventana2)

##        def segundo():
##            e,auxType = contadorMovimiento.funcionMovimientoEnRegion(y[1],10,2,lower,upper) 
##            instruction = falseType(e,auxType,Labelt,Labeli,img0,imgF)
##            if not instruction:
##                inicio(0)
##                
##        Thread(target=segundo).start()
##        Thread(target=video1()).start()
##        
##        time.sleep(10)

######################## fin instrucciones
##
        Labeli=Label(ventana2,image=img12)
        ventana2.columnconfigure(0,weight=1)
        Labeli.grid(row=2,column=0)
        ventana2.update()
        Labelt.config(text='Sus manos son seguras')
##        Labeli.config(image=img12)
##        Labeli.image=img12
        ventana2.update()
        time.sleep(5)
def inicio(c):
    global ventana2, Labeli, Labelt, img0, img1, imgF, row, cont
    instruction=None
    img0=PhotoImage(file="00.gif") # Reads photos
    img00=PhotoImage(file="0000.gif")
    imgF=PhotoImage(file="FF.gif")

    if c:  
        ventana2=Toplevel(ventana)
        ventana2.title("MANITOR")
        ventana2.configure(bg="white")
        ventana2.geometry("1000x600+5+40")
    
        Labelt=Label(ventana2,text='BIENVENIDO ', # ventana2 TEXTO
                fg="black",bg="white",font=("Helvetica 36 "))
        ventana2.columnconfigure(0,weight=1)
        Labelt.grid(row=1,column=0)
        Labeli=Label(ventana2,image=img00) # ventana2 IMAGEN
        Labeli.grid(row=2,column=0)
                
    else:
        Labelt.config(text='BIENVENIDO ')
        Labeli.image = img00
        Labeli.config(image=img00)
    ventana.iconify() # Turns window into an icon
    
    row=row+1
    cont=cont+1

    

    
    while 1:
        
        nuevoUsuario = detectUser.newUser(3,lower,upper)
        
    
        Labelt.config(text='BIENVENIDO \n  Por favor moje sus manos con agua')
        worksheet.write_datetime(row, col, date_time,f2)
        worksheet.write_datetime(row, col+1, date_time,f3)
        worksheet.write(row, col +2, cont, f6)
        worksheet.write(row, col +3, 'NUEVA PERSONA',f4)
        ventana2.update()
        video000()


        jabon()        

        primero1()
            
####################### fin instrucciones

        Labeli=Label(ventana2,image=img00)
        Labeli.grid(row=2,column=0)
        Labelt.config(text='Sus manos son seguras')
        row=row+1
        worksheet.write_datetime(row, col, date_time, f2)
        worksheet.write_datetime(row, col+1, date_time,f3)
        worksheet.write(row, col +3, 'TERMINO')
        ventana2.update()
        ventana2.after(2000)
예제 #19
0
class TraceGui(object):

    def __init__(self, trace_complete_callback=None):
        self._trace_results_callback = trace_complete_callback
        self._flow_entries_container = None

        self._root = Toplevel()
        self._root.title('FlowEntry Trace')
        self._root.minsize(width=300, height=350)
        #self._root.geometry('%dx%d+%d+%d'%(900, 700, 120, 120)) # widthxheight+x+y

        self._top_frame = Frame(self._root)
        self._top_frame.pack(side=TOP, fill=X, padx=10, pady=10)

        # TODO for now these label names have to be exactly the same as the FlowEntryMatch object properties
        #      consider either using the property values, or setting the FlowEntryMatch objects in _trace_callback()
        #      differently. This way is kind-of a hack

        # The text labels
        label_entry_frame = Frame(self._top_frame)
        label_entry_frame.pack(side=TOP, anchor=W, pady=5)
        self._in_port_label   = LabelEntry(label_entry_frame,  'in_port')
        self._dl_src_label    = LabelEntry(label_entry_frame,  'dl_src')
        self._dl_dst_label    = LabelEntry(label_entry_frame,  'dl_dst')
        self._dl_type_label   = LabelOption(label_entry_frame, 'dl_type', 'empty', 'empty', 'ARP', 'IP', 'RARP')
        self._vlan_vid_label  = LabelEntry(label_entry_frame,  'dl_vlan')
        self._vlan_pcp_label  = LabelEntry(label_entry_frame,  'dl_vlan_pcp')
        self._nw_src_label    = LabelEntry(label_entry_frame,  'nw_src')
        self._nw_dst_label    = LabelEntry(label_entry_frame,  'nw_dst')
        self._nw_tos_label    = LabelEntry(label_entry_frame,  'nw_tos')
        self._nw_proto_label  = LabelOption(label_entry_frame, 'nw_proto', 'empty', 'empty', 'ICMP', 'SCTP', 'TCP', 'UDP')
        self._tp_src_label    = LabelEntry(label_entry_frame,  'tp_src')
        self._tp_dst_label    = LabelEntry(label_entry_frame,  'tp_dst')
        # This list is used when clearing the label entries
        self._label_entries = [self._in_port_label,
                               self._dl_src_label, self._dl_dst_label, self._dl_type_label,
                               self._vlan_vid_label, self._vlan_pcp_label,
                               self._nw_src_label, self._nw_dst_label, self._nw_tos_label, self._nw_proto_label,
                               self._tp_src_label, self._tp_dst_label]

        '''
        check_frame = Frame(self._top_frame)
        check_frame.pack(side=TOP, anchor=W, pady=5)
        self._trace_display_label = LabelBase(check_frame, 'Trace display', width=18)
        radio_vals = ['FlowEntry list highlighting', 'seperate window']
        self._radio_trace_display = Radios(check_frame, radio_vals)
        '''

        # the buttons
        button_frame = Frame(self._top_frame, pady=5)
        button_frame.pack(side=BOTTOM, anchor=S)
        buttons_dict = OrderedDict([('trace', self._trace_callback), ('reset', self._reset_callback), ('cancel', self._cancel_callback)])
        Buttons(button_frame, buttons_dict, button_orientation=LEFT)

        # Hide this window until its needed
        self._root.withdraw()

        #
        # The trace results window
        #
        self._trace_result = Toplevel()
        self._trace_result.title('FlowEntry Trace Results')
        self._trace_result.minsize(width=1200, height=700)
        self._trace_result.withdraw()

        # The trace results scrollable list
        list_frame = Frame(self._trace_result)
        list_frame.pack(side=TOP, expand=YES, fill=BOTH)
        self._trace_results_list = ScrolledList(list_frame)

        # The trace results close button
        result_button_frame = Frame(self._trace_result, padx=5)
        result_button_frame.pack(side=BOTTOM, anchor=S)
        Buttons(result_button_frame, {'close' : self._trace_result.withdraw})


    def _trace_callback(self):
        #
        # Get the input specified in the Trace input window
        input_match_obj_list = []
        for label_entry in self._label_entries:
            if len(label_entry.entry_text) > 0 and label_entry.entry_text != 'empty':
                match_object = FlowEntryFactory.get_match_object(label_entry.label_text, label_entry.entry_text)
                #print '\t%s' % match_object
                input_match_obj_list.append(match_object)

        #
        # Do the tracing
        flow_tracer = FlowTracer(self._flow_entries_container, input_match_obj_list)
        # returns a dictionary of MatchedFlowEntry to (next_table, drop, output, next_input_matches)
        matched_flow_entries = flow_tracer.trace()

        #
        # Open the self._trace_result window to display the results
        self._trace_results_list.clear()
        if len(matched_flow_entries) < 1:
            Popup("No tracing matches found")
            return

        for (matched_flow_entry, results) in matched_flow_entries.iteritems():
            if matched_flow_entry.table_ < 0:
                # No match was found
                self._trace_results_list.append_list_entry('')
                self._trace_results_list.append_list_entry('No Match was found in table %s' % results[0])
                next_action = 'Drop'
            else:
                self._trace_results_list.append_list_entry('')
                self._trace_results_list.append_list_entry('Match found in table %s' % matched_flow_entry.table_)
                self._trace_results_list.append_list_entry('        Flow Entry [%s]' % matched_flow_entry)
                self._trace_results_list.append_list_entry('        Resulting Flow Entry Matches [%d]' % len(results[3]))
                for r in results[3]:
                    self._trace_results_list.append_list_entry('                [%s]' % r)
                if results[1]:     next_action = 'Drop'
                elif results[2]:   next_action = 'Output: %s' % results[2]
                else:              next_action = 'Goto Table %s' % results[0]
            self._trace_results_list.append_list_entry('        Resulting Action: [%s]' % next_action);

        # Now display the window
        self._trace_result.update()
        self._trace_result.deiconify()

        #
        # This will call the root gui to display matched flow entries
        if self._trace_results_callback:
            self._trace_results_callback(matched_flow_entries)

    def _reset_callback(self):
        # Reset all of the fields
        for label_entry in self._label_entries:
            label_entry.clear_entry()

    def _cancel_callback(self):
        self.display(False)

    def display(self, show=True):
        if show:
            self._root.update()
            self._root.deiconify()
        else:
            self._root.withdraw()

    def set_flow_entries_container(self, fe_container):
        self._flow_entries_container = fe_container

    flow_entries_conatiner = property(fset=set_flow_entries_container)