Ejemplo n.º 1
0
def draw(force = False):
    global _DIGITWIDTH, _DIGITHEIGHT, _SEGMENTWIDTH, _DIGITSPACING
    global last_draw_parameters, endTime

    w = c.winfo_width()
    h = c.winfo_height()
    _DIGITWIDTH = w / 4.3
    _DIGITHEIGHT = _DIGITWIDTH * 2
    _SEGMENTWIDTH = _DIGITWIDTH / 6.0
    _DIGITSPACING = _SEGMENTWIDTH
    x = _DIGITSPACING
    y = 0.5 * (h - _DIGITHEIGHT)

    remainingTime = endTime - time.time()
    if pausedAt != None:
        remainingTime = pausedAt
    remainingSeconds = int(math.ceil(remainingTime))

    warn = False
    if remainingSeconds <= warnInterval:
        #if int(remainingTime * 2) % 2 != 0:
        warn = True

    #seconds = max(0, math.ceil(remainingSeconds/10.0)*10)
    seconds = remainingSeconds
    colon = (remainingSeconds % 2 == 0) or (pausedAt != None)
    bgcolor = _BG
    if remainingSeconds <= 0 and remainingSeconds % 2 == 0:
        bgcolor = _BGOUT

    if remainingSeconds == 0:
        from PIL import ImageTk,Image  
        from Tkinter import Canvas, NW, Toplevel, YES, BOTH
        novi = Toplevel()
        canvas = Canvas(novi, width = 650, height = 1000)
        canvas.pack(expand = YES, fill = BOTH)
        img = ImageTk.PhotoImage(Image.open(draw_card()))  
        canvas.create_image(0,0, anchor=NW, image=img)   
        #assigned the gif1 to the canvas object
        canvas.img = img

        #restart new round
        endTime = time.time() + defaultInterval

    draw_parameters = (x, y, seconds, colon, warn, bgcolor)
    if draw_parameters != last_draw_parameters or force:
        c.delete(Tkinter.ALL)
        c.config(bg = bgcolor)
        draw_time(c, x, y, seconds=seconds, drawColon=colon, warn=warn)
        last_draw_parameters = draw_parameters
Ejemplo n.º 2
0
import Tkinter
import Image
from Tkinter import Tk, BOTH
from ttk import Frame, Button, Style
import cv2
import os
import time
import itertools
from Tkinter import Tk, Frame, BOTH, Button, RIGHT, RAISED
from Tkinter import BooleanVar, Checkbutton, PhotoImage, Canvas
from Tkinter import Scale, StringVar, END, Listbox, Label, Menu
from PIL import Image
import ttk
import thread
import pylab

root = Tk()
cwgt = Canvas(root)
cwgt.pack(expand=True, fill=BOTH)
image1 = PhotoImage(file="1.png")
# keep a link to the image to stop the image being garbage collected
cwgt.img = image1
cwgt.create_image(0, 0, image=image1)
b1 = Button(cwgt, text="Hello", bd=0)
cwgt.create_window(20, 20, window=b1)
root.mainloop()
Ejemplo n.º 3
0
now = datetime.now()
######

##################
#import ImageTk
onvideo = 1
root = Tk()

cwgt = Canvas(root)
cwgt2 = Canvas(root)

cwgt.pack(fill=BOTH, expand=False, side=RIGHT, padx=1, pady=1)
cwgt2.pack(fill=BOTH, expand=False, side=RIGHT, padx=1, pady=1)
cwgt.camera = camera
#
cwgt.img = "menu.png"

#cap = cv2.VideoCapture(0)
#startIndex = 0
#fourcc = cv2.VideoWriter_fourcc(*'XVID')
#out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))
##
#tkMessageBox.showinfo(title="dsfs",message="sdgdgd")
############


#############################################    khai bao ban dau
class Example(Frame):

    #######################################################################