def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#5b9ed8'  # Closest X11 color: 'SteelBlue3'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9' # X11 color: 'gray85'
        _ana1color = '#d9d9d9' # X11 color: 'gray85'
        _ana2color = '#d9d9d9' # X11 color: 'gray85'
        font10 = "-family {Product Sans} -size 10 -weight normal "  \
            "-slant roman -underline 0 -overstrike 0"
        font11 = "-family {Product Sans} -size 14 -weight bold -slant "  \
            "roman -underline 0 -overstrike 0"
        font12 = "-family {Product Sans} -size 12 -weight normal "  \
            "-slant roman -underline 0 -overstrike 0"
        font13 = "-family {Product Sans} -size 18 -weight bold -slant "  \
            "roman -underline 0 -overstrike 0"
        font9 = "-family {Product Sans} -size 10 -weight bold -slant "  \
            "roman -underline 0 -overstrike 0"

        top.geometry("1600x900+316+34")
        top.title("Medicine")
        top.configure(background="#455a64")
        top.configure(highlightbackground="#d9d9d9")
        top.configure(highlightcolor="black")


        root.state("zoomed")
        self.Label1 = Label(top)
        self.Label1.place(relx=0.0, rely=0.0, height=136, width=1601)
        self.Label1.configure(activebackground="#f9f9f9")
        self.Label1.configure(activeforeground="black")
        self.Label1.configure(background="#263238")
        self.Label1.configure(disabledforeground="#a3a3a3")
        self.Label1.configure(font=font13)
        self.Label1.configure(foreground="#fff")
        self.Label1.configure(highlightbackground="#d9d9d9")
        self.Label1.configure(highlightcolor="black")
        self.Label1.configure(text='''Medicine Search and Information''')

        def back():
            root.destroy()
            subprocess.call("python2 studdashscreen1.py")




        self.Button1 = Button(top)
        self.Button1.place(relx=0.925, rely=0.178, height=43, width=89)
        self.Button1.configure(activebackground="#263238")
        self.Button1.configure(activeforeground="white")
        self.Button1.configure(activeforeground="#000000")
        self.Button1.configure(background="#263238")
        self.Button1.configure(disabledforeground="#a3a3a3")
        self.Button1.configure(font=font9)
        self.Button1.configure(foreground="#fff")
        self.Button1.configure(highlightbackground="#5b9ed8")
        self.Button1.configure(highlightcolor="black")
        self.Button1.configure(pady="0")
        self.Button1.configure(text='''Back''')
        self.Button1.configure(command = back)

        self.Label2 = Label(top)
        self.Label2.place(relx=0.65, rely=0.178, height=27, width=115)
        self.Label2.configure(activebackground="#f9f9f9")
        self.Label2.configure(activeforeground="black")
        self.Label2.configure(background="#455a64")
        self.Label2.configure(disabledforeground="#a3a3a3")
        self.Label2.configure(font=font10)
        self.Label2.configure(foreground="#fff")
        self.Label2.configure(highlightbackground="#d9d9d9")
        self.Label2.configure(highlightcolor="black")
        self.Label2.configure(text='''Logged in at :''')

        self.LogInTimeLabel = Label(top)
        self.LogInTimeLabel.place(relx=0.725, rely=0.178, height=27, width=95)
        self.LogInTimeLabel.configure(activebackground="#f9f9f9")
        self.LogInTimeLabel.configure(activeforeground="black")
        self.LogInTimeLabel.configure(background="#455a64")
        self.LogInTimeLabel.configure(disabledforeground="#a3a3a3")
        self.LogInTimeLabel.configure(font=font10)
        self.LogInTimeLabel.configure(foreground="#fff")
        self.LogInTimeLabel.configure(highlightbackground="#d9d9d9")
        self.LogInTimeLabel.configure(highlightcolor="black")
        self.LogInTimeLabel.configure(text=time.strftime("%X"))

        self.Label2_2 = Label(top)
        self.Label2_2.place(relx=0.788, rely=0.178, height=27, width=45)
        self.Label2_2.configure(activebackground="#f9f9f9")
        self.Label2_2.configure(activeforeground="black")
        self.Label2_2.configure(background="#455a64")
        self.Label2_2.configure(disabledforeground="#a3a3a3")
        self.Label2_2.configure(font=font10)
        self.Label2_2.configure(foreground="#fff")
        self.Label2_2.configure(highlightbackground="#d9d9d9")
        self.Label2_2.configure(highlightcolor="black")
        self.Label2_2.configure(text='''on''')

        self.LogInDateLabel = Label(top)
        self.LogInDateLabel.place(relx=0.819, rely=0.181, height=27, width=105)
        self.LogInDateLabel.configure(activebackground="#f9f9f9")
        self.LogInDateLabel.configure(activeforeground="black")
        self.LogInDateLabel.configure(background="#455a64")
        self.LogInDateLabel.configure(disabledforeground="#a3a3a3")
        self.LogInDateLabel.configure(font=font10)
        self.LogInDateLabel.configure(foreground="#fff")
        self.LogInDateLabel.configure(highlightbackground="#d9d9d9")
        self.LogInDateLabel.configure(highlightcolor="black")
        self.LogInDateLabel.configure(text=time.strftime("%d-%m-%Y"))

        self.Label2_4 = Label(top)
        self.Label2_4.place(relx=0.013, rely=0.178, height=27, width=115)
        self.Label2_4.configure(activebackground="#f9f9f9")
        self.Label2_4.configure(activeforeground="black")
        self.Label2_4.configure(background="#455a64")
        self.Label2_4.configure(disabledforeground="#a3a3a3")
        self.Label2_4.configure(font=font10)
        self.Label2_4.configure(foreground="#fff")
        self.Label2_4.configure(highlightbackground="#d9d9d9")
        self.Label2_4.configure(highlightcolor="black")
        self.Label2_4.configure(text='''My Account :''')

        self.StudNameLabel = Label(top)
        self.StudNameLabel.place(relx=0.075, rely=0.178, height=27, width=170)
        self.StudNameLabel.configure(activebackground="#f9f9f9")
        self.StudNameLabel.configure(activeforeground="black")
        self.StudNameLabel.configure(background="#455a64")
        self.StudNameLabel.configure(disabledforeground="#a3a3a3")
        self.StudNameLabel.configure(font=font10)
        self.StudNameLabel.configure(foreground="#fff")
        self.StudNameLabel.configure(highlightbackground="#d9d9d9")
        self.StudNameLabel.configure(highlightcolor="black")
        self.StudNameLabel.configure(text = y)
        self.StudNameLabel.configure(anchor = W)

        self.Frame1 = Frame(top)
        self.Frame1.place(relx=0.688, rely=0.244, relheight=0.15, relwidth=0.297)

        self.Frame1.configure(borderwidth="2")
        self.Frame1.configure(background="#263238")
        self.Frame1.configure(highlightbackground="#d9d9d9")
        self.Frame1.configure(highlightcolor="black")
        self.Frame1.configure(width=475)

        self.Button2_6 = Button(self.Frame1)
        self.Button2_6.place(relx=0.042, rely=0.148, height=96, width=76)
        self.Button2_6.configure(activebackground="#263238")
        self.Button2_6.configure(activeforeground="white")
        self.Button2_6.configure(activeforeground="#000000")
        self.Button2_6.configure(background="#263238")
        self.Button2_6.configure(borderwidth="0")
        self.Button2_6.configure(disabledforeground="#a3a3a3")
        self.Button2_6.configure(foreground="#fff")
        self.Button2_6.configure(highlightbackground="#5b9ed8")
        self.Button2_6.configure(highlightcolor="black")
        self._img1 = ImageTk.PhotoImage(PIL.Image.open("./change.png"))
        self.Button2_6.configure(image=self._img1)
        self.Button2_6.configure(pady="0")
        self.Button2_6.configure(text='''Button''')

        self.Label2_7 = Label(self.Frame1)
        self.Label2_7.place(relx=0.253, rely=0.222, height=27, width=115)
        self.Label2_7.configure(activebackground="#263238")
        self.Label2_7.configure(activeforeground="white")
        self.Label2_7.configure(activeforeground="black")
        self.Label2_7.configure(anchor=W)
        self.Label2_7.configure(background="#263238")
        self.Label2_7.configure(disabledforeground="#a3a3a3")
        self.Label2_7.configure(font=font11)
        self.Label2_7.configure(foreground="#fff")
        self.Label2_7.configure(highlightbackground="#d9d9d9")
        self.Label2_7.configure(highlightcolor="black")
        self.Label2_7.configure(justify=RIGHT)
        self.Label2_7.configure(text='''Price''')

        self.PriceLabel = Label(self.Frame1)
        self.PriceLabel.place(relx=0.253, rely=0.519, height=46, width=272)
        self.PriceLabel.configure(activebackground="#f9f9f9")
        self.PriceLabel.configure(activeforeground="black")
        self.PriceLabel.configure(anchor=W)
        self.PriceLabel.configure(background="#263238")
        self.PriceLabel.configure(disabledforeground="#a3a3a3")
        self.PriceLabel.configure(font=font10)
        self.PriceLabel.configure(foreground="#fff")
        self.PriceLabel.configure(highlightbackground="#d9d9d9")
        self.PriceLabel.configure(highlightcolor="black")
        self.PriceLabel.configure(width=272)

        self.Frame1_1 = Frame(top)
        self.Frame1_1.place(relx=0.019, rely=0.244, relheight=0.15
                , relwidth=0.659)
        self.Frame1_1.configure(borderwidth="2")
        self.Frame1_1.configure(background="#263238")
        self.Frame1_1.configure(highlightbackground="#d9d9d9")
        self.Frame1_1.configure(highlightcolor="black")
        self.Frame1_1.configure(width=1055)

        self.Frame1_2 = Frame(self.Frame1_1)
        self.Frame1_2.place(relx=0.559, rely=1.963, relheight=4.63
                , relwidth=0.431)
        self.Frame1_2.configure(borderwidth="2")
        self.Frame1_2.configure(background="#263238")
        self.Frame1_2.configure(highlightbackground="#d9d9d9")
        self.Frame1_2.configure(highlightcolor="black")
        self.Frame1_2.configure(width=455)

        self.Label2_6 = Label(self.Frame1_1)
        self.Label2_6.place(relx=0.085, rely=0.444, height=27, width=115)
        self.Label2_6.configure(activebackground="#263238")
        self.Label2_6.configure(activeforeground="white")
        self.Label2_6.configure(activeforeground="black")
        self.Label2_6.configure(anchor=E)
        self.Label2_6.configure(background="#263238")
        self.Label2_6.configure(disabledforeground="#a3a3a3")
        self.Label2_6.configure(font=font11)
        self.Label2_6.configure(foreground="#fff")
        self.Label2_6.configure(highlightbackground="#d9d9d9")
        self.Label2_6.configure(highlightcolor="black")
        self.Label2_6.configure(justify=RIGHT)
        self.Label2_6.configure(text='''Search''')

        self.Text1 = Text(self.Frame1_1)
        self.Text1.place(relx=0.218, rely=0.444, relheight=0.252, relwidth=0.535)

        self.Text1.configure(background="white")
        self.Text1.configure(font="TkTextFont")
        self.Text1.configure(foreground="black")
        self.Text1.configure(highlightbackground="#5b9ed8")
        self.Text1.configure(highlightcolor="black")
        self.Text1.configure(insertbackground="black")
        self.Text1.configure(selectbackground="#c4c4c4")
        self.Text1.configure(selectforeground="black")
        self.Text1.configure(width=564)
        self.Text1.configure(wrap=WORD)

        def onClick():
            medicineName = self.Text1.get("1.0","end-1c")
            #print type(medicineName)
            if not medicineName.strip():
                #print "no medicine name provided"
                self.DrugLabel.configure(text="You need to enter a mdecine")
                self.PriceLabel.configure(text="You need to enter a mdecine")
                self.ConstituentLabel.configure(text="You need to enter a mdecine")
                self.PackLabel.configure(text="You need to enter a mdecine")
                self.UsesLabelInfo_7.configure(text="None")
                self.UsesLabelInfo_4.configure(text="None")
                self.UsesLabelInfo_6.configure(text="None")
                return
            else:
                priyamFunc(medicineName)
                with open("manufac.txt", "r+") as fptr:
                    x = fptr.readlines()
                if x[0] == " ":
                    self.DrugLabel.configure(text="No medicine found")
                    self.PriceLabel.configure(text="No medicine found")
                    self.ConstituentLabel.configure(text="No medicine found")
                    self.PackLabel.configure(text="No medicine found")
                else:
                    self.DrugLabel.configure(text=x[0])
                    self.PriceLabel.configure(text=x[1])
                    self.ConstituentLabel.configure(text=x[2])
                    self.PackLabel.configure(text=x[3])

                with open("theraUses.txt","r") as fptr:
                    uses = fptr.readlines()
                    strr = ""
                if uses[0]== " ":
                    self.UsesLabelInfo_7.configure(text="None")
                else:
                    for i in range(0,len(uses)):
                        strr = strr + uses[i] + "\n"
                        self.UsesLabelInfo_7.configure(text=strr)

                with open("sideEffects.txt", "r") as fptr:
                    side = fptr.readlines()
                    SideStrr = ""
                if uses[0] == " ":
                    self.UsesLabelInfo_6.configure(text="None")
                else:
                    for i in range(0, len(side)):
                        SideStrr = SideStrr + side[i] +"\n"
                        self.UsesLabelInfo_6.configure(text=SideStrr)
                with open("similar.txt", "r") as fptr:
                    similarMeds = str(fptr.read())
                    similarMeds = ast.literal_eval(similarMeds)
                    similarStrName = ""
                    similarStrPrice = ""
                if similarMeds[0]['name']==" ":
                    self.UsesLabelInfo_4.configure(text="None")
                else:
                    for i in range(0,len(similarMeds)):
                        similarStrName = similarStrName +"Name : " + similarMeds[i]['name']+"\n"+"Price : "+str(similarMeds[i]['price']) + "\n" + "Manufacturer : "+similarMeds[i]['manufacturer']+"\n" + "--------------------" + "\n"
                        self.UsesLabelInfo_4.configure(text=similarStrName)




        self.Button2 = Button(self.Frame1_1)
        self.Button2.place(relx=0.777, rely=0.444, height=33, width=86)
        self.Button2.configure(activebackground="#263238")
        self.Button2.configure(activeforeground="white")
        self.Button2.configure(activeforeground="#000000")
        self.Button2.configure(background="#263238")
        self.Button2.configure(disabledforeground="#a3a3a3")
        self.Button2.configure(foreground="#fff")
        self.Button2.configure(highlightbackground="#5b9ed8")
        self.Button2.configure(highlightcolor="black")
        self.Button2.configure(pady="0")
        self.Button2.configure(text='''Go''')
        self.Button2.configure(width=86)
        self.Button2.configure(command=onClick)

        self.Frame1_3 = Frame(top)
        self.Frame1_3.place(relx=0.019, rely=0.411, relheight=0.55
                , relwidth=0.216)
        self.Frame1_3.configure(borderwidth="2")
        self.Frame1_3.configure(background="#263238")
        self.Frame1_3.configure(highlightbackground="#d9d9d9")
        self.Frame1_3.configure(highlightcolor="black")
        self.Frame1_3.configure(width=345)

        self.Label2_1 = Label(self.Frame1_3)
        self.Label2_1.place(relx=0.058, rely=0.04, height=27, width=65)
        self.Label2_1.configure(activebackground="#263238")
        self.Label2_1.configure(activeforeground="white")
        self.Label2_1.configure(activeforeground="black")
        self.Label2_1.configure(anchor=W)
        self.Label2_1.configure(background="#263238")
        self.Label2_1.configure(disabledforeground="#a3a3a3")
        self.Label2_1.configure(font=font11)
        self.Label2_1.configure(foreground="#fff")
        self.Label2_1.configure(highlightbackground="#d9d9d9")
        self.Label2_1.configure(highlightcolor="black")
        self.Label2_1.configure(justify=RIGHT)
        self.Label2_1.configure(text='''Uses''')
        self.Label2_1.configure(width=65)

        self.UsesLabelInfo_7 = Label(self.Frame1_3)
        self.UsesLabelInfo_7.place(
            relx=0.06, rely=0.130, height=380, width=280)

        self.UsesLabelInfo_7.configure(activebackground="#263238")
        self.UsesLabelInfo_7.configure(activeforeground="white")
        self.UsesLabelInfo_7.configure(activeforeground="black")
        self.UsesLabelInfo_7.configure(anchor=NW)
        self.UsesLabelInfo_7.configure(background="#455A64")
        self.UsesLabelInfo_7.configure(disabledforeground="#a3a3a3")
        self.UsesLabelInfo_7.configure(font=font12)
        self.UsesLabelInfo_7.configure(foreground="#fff")
        self.UsesLabelInfo_7.configure(highlightbackground="#d9d9d9")
        self.UsesLabelInfo_7.configure(highlightcolor="black")
        self.UsesLabelInfo_7.configure(justify=LEFT)

        self.RegNoLabel = Label(top)
        self.RegNoLabel.place(relx=0.169, rely=0.178, height=27, width=115)
        self.RegNoLabel.configure(activebackground="#f9f9f9")
        self.RegNoLabel.configure(activeforeground="black")
        self.RegNoLabel.configure(background="#455a64")
        self.RegNoLabel.configure(disabledforeground="#a3a3a3")
        self.RegNoLabel.configure(font=font10)
        self.RegNoLabel.configure(foreground="#fff")
        self.RegNoLabel.configure(highlightbackground="#d9d9d9")
        self.RegNoLabel.configure(highlightcolor="black")

        self.Frame1_11 = Frame(top)
        self.Frame1_11.place(relx=0.688, rely=0.411, relheight=0.15
                , relwidth=0.297)
        self.Frame1_11.configure(borderwidth="2")
        self.Frame1_11.configure(background="#263238")
        self.Frame1_11.configure(highlightbackground="#d9d9d9")
        self.Frame1_11.configure(highlightcolor="black")
        self.Frame1_11.configure(width=475)

        self.Button2_12 = Button(self.Frame1_11)
        self.Button2_12.place(relx=0.042, rely=0.148, height=96, width=76)
        self.Button2_12.configure(activebackground="#263238")
        self.Button2_12.configure(activeforeground="white")
        self.Button2_12.configure(activeforeground="#000000")
        self.Button2_12.configure(background="#263238")
        self.Button2_12.configure(borderwidth="0")
        self.Button2_12.configure(disabledforeground="#a3a3a3")
        self.Button2_12.configure(foreground="#fff")
        self.Button2_12.configure(highlightbackground="#5b9ed8")
        self.Button2_12.configure(highlightcolor="black")
        self._img2 = ImageTk.PhotoImage(PIL.Image.open("./manufacturing.png"))
        self.Button2_12.configure(image=self._img2)
        self.Button2_12.configure(pady="0")
        self.Button2_12.configure(text='''Button''')

        self.Label2_9 = Label(self.Frame1_11)
        self.Label2_9.place(relx=0.253, rely=0.148, height=27, width=155)
        self.Label2_9.configure(activebackground="#263238")
        self.Label2_9.configure(activeforeground="white")
        self.Label2_9.configure(activeforeground="black")
        self.Label2_9.configure(anchor=W)
        self.Label2_9.configure(background="#263238")
        self.Label2_9.configure(disabledforeground="#a3a3a3")
        self.Label2_9.configure(font=font11)
        self.Label2_9.configure(foreground="#fff")
        self.Label2_9.configure(highlightbackground="#d9d9d9")
        self.Label2_9.configure(highlightcolor="black")
        self.Label2_9.configure(justify=RIGHT)
        self.Label2_9.configure(text='''Manufacturer''')
        self.Label2_9.configure(width=155)

        self.DrugLabel = Label(self.Frame1_11)
        self.DrugLabel.place(relx=0.253, rely=0.444, height=46, width=272)
        self.DrugLabel.configure(activebackground="#f9f9f9")
        self.DrugLabel.configure(activeforeground="black")
        self.DrugLabel.configure(anchor=W)
        self.DrugLabel.configure(background="#263238")
        self.DrugLabel.configure(disabledforeground="#a3a3a3")
        self.DrugLabel.configure(font=font10)
        self.DrugLabel.configure(foreground="#fff")
        self.DrugLabel.configure(highlightbackground="#d9d9d9")
        self.DrugLabel.configure(highlightcolor="black")
        self.DrugLabel.configure(width=272)

        self.Frame1_12 = Frame(top)
        self.Frame1_12.place(relx=0.688, rely=0.578, relheight=0.183
                , relwidth=0.297)
        self.Frame1_12.configure(borderwidth="2")
        self.Frame1_12.configure(background="#263238")
        self.Frame1_12.configure(highlightbackground="#d9d9d9")
        self.Frame1_12.configure(highlightcolor="black")
        self.Frame1_12.configure(width=475)

        self.Button2_13 = Button(self.Frame1_12)
        self.Button2_13.place(relx=0.042, rely=0.182, height=96, width=76)
        self.Button2_13.configure(activebackground="#263238")
        self.Button2_13.configure(activeforeground="white")
        self.Button2_13.configure(activeforeground="#000000")
        self.Button2_13.configure(background="#263238")
        self.Button2_13.configure(borderwidth="0")
        self.Button2_13.configure(disabledforeground="#a3a3a3")
        self.Button2_13.configure(foreground="#fff")
        self.Button2_13.configure(highlightbackground="#5b9ed8")
        self.Button2_13.configure(highlightcolor="black")
        self._img3 = ImageTk.PhotoImage(PIL.Image.open("./studentpack.png"))
        self.Button2_13.configure(image=self._img3)
        self.Button2_13.configure(pady="0")
        self.Button2_13.configure(text='''Button''')

        self.Label2_3 = Label(self.Frame1_12)
        self.Label2_3.place(relx=0.253, rely=0.182, height=27, width=115)
        self.Label2_3.configure(activebackground="#263238")
        self.Label2_3.configure(activeforeground="white")
        self.Label2_3.configure(activeforeground="black")
        self.Label2_3.configure(anchor=W)
        self.Label2_3.configure(background="#263238")
        self.Label2_3.configure(disabledforeground="#a3a3a3")
        self.Label2_3.configure(font=font11)
        self.Label2_3.configure(foreground="#fff")
        self.Label2_3.configure(highlightbackground="#d9d9d9")
        self.Label2_3.configure(highlightcolor="black")
        self.Label2_3.configure(justify=RIGHT)
        self.Label2_3.configure(text='''Packaging''')

        self.PackLabel = Label(self.Frame1_12)
        self.PackLabel.place(relx=0.253, rely=0.424, height=46, width=272)
        self.PackLabel.configure(activebackground="#f9f9f9")
        self.PackLabel.configure(activeforeground="black")
        self.PackLabel.configure(anchor=W)
        self.PackLabel.configure(background="#263238")
        self.PackLabel.configure(disabledforeground="#a3a3a3")
        self.PackLabel.configure(font=font10)
        self.PackLabel.configure(foreground="#fff")
        self.PackLabel.configure(highlightbackground="#d9d9d9")
        self.PackLabel.configure(highlightcolor="black")
        self.PackLabel.configure(width=272)

        self.Frame1_4 = Frame(top)
        self.Frame1_4.place(relx=0.688, rely=0.778, relheight=0.183
                , relwidth=0.297)
        self.Frame1_4.configure(borderwidth="2")
        self.Frame1_4.configure(background="#263238")
        self.Frame1_4.configure(highlightbackground="#d9d9d9")
        self.Frame1_4.configure(highlightcolor="black")
        self.Frame1_4.configure(width=475)

        self.Button2_4 = Button(self.Frame1_4)
        self.Button2_4.place(relx=0.042, rely=0.182, height=96, width=76)
        self.Button2_4.configure(activebackground="#263238")
        self.Button2_4.configure(activeforeground="white")
        self.Button2_4.configure(activeforeground="#000000")
        self.Button2_4.configure(background="#263238")
        self.Button2_4.configure(borderwidth="0")
        self.Button2_4.configure(disabledforeground="#a3a3a3")
        self.Button2_4.configure(foreground="#fff")
        self.Button2_4.configure(highlightbackground="#5b9ed8")
        self.Button2_4.configure(highlightcolor="black")
        self._img4 = ImageTk.PhotoImage(PIL.Image.open("./vitamin-c.png"))
        self.Button2_4.configure(image=self._img4)
        self.Button2_4.configure(pady="0")
        self.Button2_4.configure(text='''Button''')

        self.Label2_5 = Label(self.Frame1_4)
        self.Label2_5.place(relx=0.253, rely=0.182, height=27, width=145)
        self.Label2_5.configure(activebackground="#263238")
        self.Label2_5.configure(activeforeground="white")
        self.Label2_5.configure(activeforeground="black")
        self.Label2_5.configure(anchor=W)
        self.Label2_5.configure(background="#263238")
        self.Label2_5.configure(disabledforeground="#a3a3a3")
        self.Label2_5.configure(font=font11)
        self.Label2_5.configure(foreground="#fff")
        self.Label2_5.configure(highlightbackground="#d9d9d9")
        self.Label2_5.configure(highlightcolor="black")
        self.Label2_5.configure(justify=RIGHT)
        self.Label2_5.configure(text='''Constituent''')

        self.ConstituentLabel = Label(self.Frame1_4)
        self.ConstituentLabel.place(relx=0.253, rely=0.424, height=46, width=272)

        self.ConstituentLabel.configure(activebackground="#f9f9f9")
        self.ConstituentLabel.configure(activeforeground="black")
        self.ConstituentLabel.configure(anchor=W)
        self.ConstituentLabel.configure(background="#263238")
        self.ConstituentLabel.configure(disabledforeground="#a3a3a3")
        self.ConstituentLabel.configure(font=font10)
        self.ConstituentLabel.configure(foreground="#fff")
        self.ConstituentLabel.configure(highlightbackground="#d9d9d9")
        self.ConstituentLabel.configure(highlightcolor="black")
        self.ConstituentLabel.configure(width=272)

        self.Frame1_1 = Frame(top)
        self.Frame1_1.place(relx=0.244, rely=0.411, relheight=0.55
                , relwidth=0.209)
        self.Frame1_1.configure(borderwidth="2")
        self.Frame1_1.configure(background="#263238")
        self.Frame1_1.configure(highlightbackground="#d9d9d9")
        self.Frame1_1.configure(highlightcolor="black")
        self.Frame1_1.configure(width=335)

        self.Label2_2 = Label(self.Frame1_1)
        self.Label2_2.place(relx=0.06, rely=0.04, height=27, width=135)
        self.Label2_2.configure(activebackground="#263238")
        self.Label2_2.configure(activeforeground="white")
        self.Label2_2.configure(activeforeground="black")
        self.Label2_2.configure(anchor=W)
        self.Label2_2.configure(background="#263238")
        self.Label2_2.configure(disabledforeground="#a3a3a3")
        self.Label2_2.configure(font=font11)
        self.Label2_2.configure(foreground="#fff")
        self.Label2_2.configure(highlightbackground="#d9d9d9")
        self.Label2_2.configure(highlightcolor="black")
        self.Label2_2.configure(justify=RIGHT)
        self.Label2_2.configure(text='''Side Effects''')

        self.UsesLabelInfo_6 = Label(self.Frame1_1)
        self.UsesLabelInfo_6.place(
            relx=0.06, rely=0.130, height=380, width=280)

        self.UsesLabelInfo_6.configure(activebackground="#263238")
        self.UsesLabelInfo_6.configure(activeforeground="white")
        self.UsesLabelInfo_6.configure(activeforeground="black")
        self.UsesLabelInfo_6.configure(anchor=NW)
        self.UsesLabelInfo_6.configure(background="#455A64")
        self.UsesLabelInfo_6.configure(disabledforeground="#a3a3a3")
        self.UsesLabelInfo_6.configure(font=font10)
        self.UsesLabelInfo_6.configure(foreground="#fff")
        self.UsesLabelInfo_6.configure(highlightbackground="#d9d9d9")
        self.UsesLabelInfo_6.configure(highlightcolor="black")
        self.UsesLabelInfo_6.configure(justify=LEFT)

        self.Frame1_5 = Frame(top)
        self.Frame1_5.place(relx=0.463, rely=0.411, relheight=0.55
                , relwidth=0.216)
        self.Frame1_5.configure(borderwidth="2")
        self.Frame1_5.configure(background="#263238")
        self.Frame1_5.configure(highlightbackground="#d9d9d9")
        self.Frame1_5.configure(highlightcolor="black")
        self.Frame1_5.configure(width=345)

        self.Label2_3 = Label(self.Frame1_5)
        self.Label2_3.place(relx=0.058, rely=0.04, height=27, width=135)
        self.Label2_3.configure(activebackground="#263238")
        self.Label2_3.configure(activeforeground="white")
        self.Label2_3.configure(activeforeground="black")
        self.Label2_3.configure(anchor=NW)
        self.Label2_3.configure(background="#263238")
        self.Label2_3.configure(disabledforeground="#a3a3a3")
        self.Label2_3.configure(font=font11)
        self.Label2_3.configure(foreground="#fff")
        self.Label2_3.configure(highlightbackground="#d9d9d9")
        self.Label2_3.configure(highlightcolor="black")
        self.Label2_3.configure(justify=LEFT)
        self.Label2_3.configure(text='''Substitutes''')

        self.UsesLabelInfo_4 = Label(self.Frame1_5)
        self.UsesLabelInfo_4.place(
            relx=0.05, rely=0.130, height=380, width=310)

        self.UsesLabelInfo_4.configure(activebackground="#263238")
        self.UsesLabelInfo_4.configure(activeforeground="white")
        self.UsesLabelInfo_4.configure(activeforeground="black")
        self.UsesLabelInfo_4.configure(anchor=NW)
        self.UsesLabelInfo_4.configure(background="#455A64")
        self.UsesLabelInfo_4.configure(disabledforeground="#a3a3a3")
        self.UsesLabelInfo_4.configure(font=font10)
        self.UsesLabelInfo_4.configure(foreground="#fff")
        self.UsesLabelInfo_4.configure(highlightbackground="#d9d9d9")
        self.UsesLabelInfo_4.configure(highlightcolor="black")
        self.UsesLabelInfo_4.configure(justify=LEFT)
def render_bitmap(start, end, force):
    global data, width, canvas, list_image, list_imagetk, list_canvas, list_rendered, color_dict, bg_color, thread_event, abort

    if start < 0:
        start = 0
    if end > (len(data) // (width * width)) + 1:
        end = (len(data) // (width * width)) + 1

    bytes_rendered = start * width * width
    height_rendered = start * width

    for n in range(start, end):
        # Abort rendering if window is closed
        if abort == True:
            return

        # Pause rendering while dragging canvas
        thread_event.wait()

        # Skip already rendered region
        if list_rendered[n] == True and force == False:
            continue

        remain = len(data) - bytes_rendered
        if remain // width < width:
            unit_height = remain // width
        else:
            unit_height = width

        bg_color = "white"
        image = Image.new(mode="RGB", size=(width, unit_height))
        draw = ImageDraw.Draw(image)
        draw.rectangle((0, 0, width, unit_height), fill=color_dict[bg_color], outline=color_dict[bg_color])

        for i in range(width * height_rendered, (width * height_rendered) + (width * unit_height)):
            # Abort rendering if window is closed
            if abort == True:
                return

            x = i % width
            y = (i // width) - height_rendered

            if data[i] == 0:
                if bg_color != "white":
                    image.putpixel((x, y), color_dict["white"])
            elif data[i] < 0x20 or data[i] == 0x7f:
                if bg_color != "blue":
                    image.putpixel((x, y), color_dict["blue"])
            elif data[i] < 0x80:
                if bg_color != "red":
                    image.putpixel((x, y), color_dict["red"])
            elif data[i] >= 0x80:
                if bg_color != "black":
                    image.putpixel((x, y), color_dict["black"])

        try:
            imagetk = ImageTk.PhotoImage(image=image)

            if unit_height < width:
                can = canvas.create_image(0, height_rendered - ((width - unit_height) // 2) - 1, image=imagetk)
            else:
                can = canvas.create_image(0, height_rendered, image=imagetk)
        except:
            pass # Ignore exception on closing window

        # Retain rendered images to avoid garbage collection
        list_image.append(image)
        list_imagetk.append(imagetk)
        list_canvas.append(can)

        bytes_rendered += width * unit_height
        height_rendered += unit_height
        list_rendered[n] = True
Beispiel #3
0
canvas.configure(yscrollcommand=myscrollbar.set)

myscrollbar.pack(side="right", fill="y")
canvas.pack(side="left")
canvas.create_window((0, 0), window=frame, anchor='nw')
frame.bind("<Configure>", myfunction)

# appFrame = Frame(width=400, height=600, bg='#23314A')

emptyFrame = Frame(frame, height=10, bg='#23314A')
emptyFrame.pack()

titleFrame = Frame(frame, width=400, bg='#23314A')
image1 = Image.open("zoomer_icon128.png")
image1 = image1.resize((int(image1.size[0] * .35), int(image1.size[1] * .35)))
test = ImageTk.PhotoImage(image1)

label1 = Label(titleFrame, image=test, bg="#23314A")
label1.image = test
label1.grid(column=0, row=0)

label2 = Label(titleFrame,
               text="Zoomer",
               font=('Arial', 25),
               bg="#23314A",
               fg="white")
label2.grid(column=1, row=0)
titleFrame.pack()

emptyFrame = Frame(frame, height=10, bg='#23314A')
emptyFrame.pack()
from tkinter import *
from PIL import ImageTk,Image

root = Tk()
root.title('Learn Tkinter')
root.iconbitmap('./images/favicon.ico')  # add icon

# add images
my_img = ImageTk.PhotoImage(Image.open('./images/wuqian_01.jpg'))
my_label = Label(image=my_img)
my_label.pack()

# Quit Button
button_quit = Button(root, text='Exit Program', command=root.quit)
button_quit.pack()



root.mainloop()
##secLabel = Tkinter.Label(secFrame, text="Welcome to Automated DR Identifier System", font=("Helvetica", 16))
##secLabel.place(x=200,y=170)
##secDesLabel = Tkinter.Label(secFrame, text="Click \"Next\" to get started!!")
##secDesLabel.place(x=200,y=210)

btnQuit_secFrame = Tkinter.Button(secFrame, text="Close", width=8)
btnQuit_secFrame.place(x=650, y=450)
btnNext_secFrame = Tkinter.Button(secFrame, text="Next", width=8)
btnNext_secFrame.place(x=575, y=450)

img = Image.open(
    "C:\\Users\\Imran Ullah\\Desktop\\FYP\\GUI - FYP2\\Images\\6_left-grayscale.png"
)
h, w = img.size
#print (500 , " " , w+100)
imgRes = img.resize((int(h * 2), int(w * 2)), Image.ANTIALIAS)
imgTk = ImageTk.PhotoImage(image=imgRes)

#img = cv2.imread('C:\\Users\\Imran Ullah\\Desktop\\FYP\\Images\\17_right.jpeg')
#labelImg = Tkinter.Label(MainWindow, image = imgTk)
#labelImg.grid(column=4, row = 1, pady = 10)
#panel.pack(side = "bottom", fill = "both")
#labelImg.place(x=3,.30, y =100)

### Hiding all Frames except Welcome Frame ###
secFrame.place_forget()

# Start Tkinter event - loop
MainWindow.mainloop()
Beispiel #6
0
win.geometry("870x650")
# win.geometry("{0}x{1}+0+0".format(500, win.winfo_screenheight()))
win.configure(background="cyan")
win.title("Dota 2 Game Result Prediction By Hitesh")
win.iconbitmap('1.ico')

title = Label(win,
              text="Dota 2 Game Result Prediction",
              bg="gray",
              width="30",
              height="2",
              fg="White",
              font=("Calibri 20 bold italic underline"))
title.place(x=0, y=0)

my_img = ImageTk.PhotoImage(Image.open("1.jpg"))
my_label = Label(image=my_img)
my_label.place(x=400, y=0)

cluster = IntVar()
gm = IntVar()
gt = IntVar()

g1 = IntVar()
g2 = IntVar()
g3 = IntVar()
g4 = IntVar()
g5 = IntVar()
g6 = IntVar()
g7 = IntVar()
g8 = IntVar()
Beispiel #7
0
    def get_weather(self):
        try:

            if latitude is None and longitude is None:
                # get location
                location_req_url = "http://freegeoip.net/json/%s" % self.get_ip()
                r = requests.get(location_req_url)
                location_obj = json.loads(r.text)

                lat = location_obj['latitude']
                lon = location_obj['longitude']

                location2 = "%s, %s" % (location_obj['city'], location_obj['region_code'])

                # get weather
                weather_req_url = "https://api.darksky.net/forecast/%s/%s,%s?lang=%s&units=%s" % (weather_api_token, lat,lon,weather_lang,weather_unit)
            else:
                location2 = ""
                # get weather
                weather_req_url = "https://api.darksky.net/forecast/%s/%s,%s?lang=%s&units=%s" % (weather_api_token, latitude, longitude, weather_lang, weather_unit)

            r = requests.get(weather_req_url)
            weather_obj = json.loads(r.text)

            degree_sign= u'\N{DEGREE SIGN}'
            temperature2 = "%s%s" % (str(int(weather_obj['currently']['temperature'])), degree_sign)
            currently2 = weather_obj['currently']['summary']
            forecast2 = weather_obj["hourly"]["summary"]

            icon_id = weather_obj['currently']['icon']
            icon2 = None

            if icon_id in icon_lookup:
                icon2 = icon_lookup[icon_id]

            if icon2 is not None:
                if self.icon != icon2:
                    self.icon = icon2
                    image = Image.open(icon2)
                    image = image.resize((100, 100), Image.ANTIALIAS)
                    image = image.convert('RGB')
                    photo = ImageTk.PhotoImage(image)

                    self.iconLbl.config(image=photo)
                    self.iconLbl.image = photo
            else:
                # remove image
                self.iconLbl.config(image='')

            if self.currently != currently2:
                self.currently = currently2
                self.currentlyLbl.config(text=currently2)
            if self.forecast != forecast2:
                self.forecast = forecast2
                self.forecastLbl.config(text=forecast2)
            if self.temperature != temperature2:
                self.temperature = temperature2
                self.temperatureLbl.config(text=temperature2)
            if self.location != location2:
                if location2 == ", ":
                    self.location = "Cannot Pinpoint Location"
                    self.locationLbl.config(text="Cannot Pinpoint Location")
                else:
                    self.location = location2
                    self.locationLbl.config(text=location2)
        except Exception as e:
            traceback.print_exc()
            print "Error: %s. Cannot get weather." % e

        self.after(600000, self.get_weather)
#!/usr/bin/env python3

import tkinter as tk
from PIL import ImageTk, Image

root = tk.Tk()
root.title("Image viewer")
# Set the icon for the window manager
wm_icon = tk.PhotoImage(file="images/icon.png")
root.call('wm', 'iconphoto', root._w, wm_icon)

# get all the images
my_img1 = ImageTk.PhotoImage(Image.open("images/img1.jpg"))
my_img2 = ImageTk.PhotoImage(Image.open("images/img2.jpg"))
my_img3 = ImageTk.PhotoImage(Image.open("images/img3.jpeg"))
my_img4 = ImageTk.PhotoImage(Image.open("images/img4.jpg"))
my_img5 = ImageTk.PhotoImage(Image.open("images/img5.jpeg"))
my_img6 = ImageTk.PhotoImage(Image.open("images/img6.jpg"))

# put the images in a list
image_list = [my_img1, my_img2, my_img3, my_img4, my_img5, my_img6]

# Make a label for the status bar
status = tk.Label(
    root, text=f"Image 1 of {len(image_list)} ", bd=1, relief=tk.SUNKEN, anchor=tk.E)
# label that will show the current image
my_label = tk.Label(image=my_img1)
my_label.grid(row=0, column=0, columnspan=3)


def forward(image_num):
Beispiel #9
0
 def loadImage(self):
     cardImage = Img.open(os.path.join(dirname, 'resourcesv2/'+self.shape+self.color+self.shading+str(self.amount)+'.png'))
     resizedCardImage = cardImage.resize((self.shapeWidth*self.amount + self.distBetweenShapes*(self.amount-1), self.shapeHeight), Img.ANTIALIAS)
     tkCardImage = ImgTk.PhotoImage(resizedCardImage)
     allImages.append(tkCardImage)
     return tkCardImage
def distribution_update(*args):
    sample_button.config(text="Sample from the " + distribution.get())
    if distribution.get() == "Uniform Distribution":
        # Remove parameter fields from other distributions
        mu_label.place_forget()
        mu_field.place_forget()
        sigma_label.place_forget()
        sigma_field.place_forget()
        lamb_label.place_forget()
        lamb_field.place_forget()

        # Add parameter fields of chosen distribution
        a_label.place(x=660, y=0, width=91, height=30)
        a_field.place(x=751, y=0, width=91, height=30)
        b_label.place(x=842, y=0, width=91, height=30)
        b_field.place(x=933, y=0, width=91, height=30)

        # Change the displayed pdf formula
        pdf_img = ImageTk.PhotoImage(Image.open("uniform_pdf.png"))
        pdf_formula.config(image=pdf_img)
        pdf_formula.image = pdf_img  # keep a reference!
    elif distribution.get() == "Normal Distribution":
        # Remove parameter fields from other distributions
        a_label.place_forget()
        a_field.place_forget()
        b_label.place_forget()
        b_field.place_forget()
        lamb_label.place_forget()
        lamb_field.place_forget()

        # Add parameter fields of chosen distribution
        mu_label.place(x=660, y=0, width=91, height=30)
        mu_field.place(x=751, y=0, width=91, height=30)
        sigma_label.place(x=842, y=0, width=91, height=30)
        sigma_field.place(x=933, y=0, width=91, height=30)

        # Change the displayed pdf formula
        pdf_img = ImageTk.PhotoImage(Image.open("normal_pdf.png"))
        pdf_formula.config(image=pdf_img)
        pdf_formula.image = pdf_img  # keep a reference!
    elif distribution.get() == "Exponential Distribution":
        # Remove parameter fields from other distributions
        a_label.place_forget()
        a_field.place_forget()
        b_label.place_forget()
        b_field.place_forget()
        mu_label.place_forget()
        mu_field.place_forget()
        sigma_label.place_forget()
        sigma_field.place_forget()

        # Add parameter fields of chosen distribution
        lamb_label.place(x=660, y=0, width=91, height=30)
        lamb_field.place(x=751, y=0, width=91, height=30)

        # Change the displayed pdf formula
        pdf_img = ImageTk.PhotoImage(Image.open("exponential_pdf.png"))
        pdf_formula.config(image=pdf_img)
        pdf_formula.image = pdf_img  # keep a reference!
    #Call the function to update the plot
    update_plot()
Beispiel #11
0
pasekMenu=Menu(glowneOkno)
pierwszeMenu=Menu(pasekMenu,tearoff=0)

pierwszeMenu.add_command(label="Zaktualizuj bazę cytatów",command=baza_both)
pierwszeMenu.add_command(label="Zamknij",command=glowneOkno.quit)
pasekMenu.add_cascade(label="Opcje",menu=pierwszeMenu)

pomocMenu=Menu(pasekMenu,tearoff=0)
pomocMenu.add_command(label="O Autorach",command=autorzy)
pasekMenu.add_cascade(label="Autorzy",menu=pomocMenu)

#daje logo i kocham śledzie

logo_canvas= Canvas(glowneOkno,width=500,height=150)
logo_canvas.pack()
logo_pliczek=ImageTk.PhotoImage(Image.open('logo.gif'))
logo_canvas.create_image(250,60,image=logo_pliczek)

przycisk_rozpoczecie=Button(glowneOkno,text="Rozpocznij grę!",command=zacznij_gierke)
przycisk_rozpoczecie.pack()

zespol = StringVar(glowneOkno, value="https://www.tekstowo.pl/piosenki_artysty,golec_uorkiestra")
zmiana_zespolu_tekst=Label(glowneOkno, text="\nPodaj adres do strony tekstowo.pl wybranego zespołu:")
zmiana_zespolu_tekst.pack()
zmiana_zespolu=Entry(glowneOkno, textvariable=zespol, width=40)
zmiana_zespolu.pack()
zmiana_zespolu_przycisk=Button(glowneOkno, text="Zmień przeciwnika!", command=baza_przeciwnik)
zmiana_zespolu_przycisk.pack()

glowneOkno.config(menu=pasekMenu)
glowneOkno.geometry('960x640')
Beispiel #12
0
 def visor(self):
     ret, frame = self.get_frame()
     if ret:
         self.photo = ImageTk.PhotoImage(image=Image.fromarray(frame))
         self.canvas.create_image(0, 0, image=self.photo, anchor=NW)
         self.ventana.after(15, self.visor)
        print('element_count_pic:', element_count_pic)
        print('element_count_text:', element_count_text)
    else:
        pass


def clear_element():
    for i in range(element_count_pic):
        delete_element()
        print('clear work')


################ Delete Topology #############################

################ Add an element in Topology #############################
img1 = ImageTk.PhotoImage(Image.open(Img_Trace))


def add_trace():
    global dict_pic
    global dict_text
    global element_count_pic
    global element_count_text
    element_count_pic += 1
    element_count_text += 1
    dict_pic.update({element_count_pic: element_count_pic})
    dict_text1.update({element_count_text: element_count_text})
    dict_text2.update({element_count_text: element_count_text})
    dict_pic[element_count_pic] = tk.Label(frame2, imag=img1)
    dict_pic[element_count_pic].grid(row=0,
                                     column=element_count_pic,
Beispiel #14
0
    es.set(str(round(now1)))


def transtime():
    format_time = time.strftime("%Y-%m-%d %H:%M:%S",
                                time.localtime(float(es.get())))
    e2s.set(format_time)


def strtranstime():
    ts = time.strptime(e2s.get(), "%Y-%m-%d %H:%M:%S")
    e3s.set(round(time.mktime(ts)))


b = tkinter.Button(main, text="获取当前时间戳", command=resetnowtime)
b.pack()
e2s = tkinter.StringVar()
e2 = tkinter.Entry(main, textvariable=e2s)
e2.pack()
b1 = tkinter.Button(main, text="时间戳转换", command=transtime)
b1.pack()
e3s = tkinter.StringVar()
e3 = tkinter.Entry(main, textvariable=e3s)
e3.pack()
b2 = tkinter.Button(main, text="转换时间戳", command=strtranstime)
b2.pack()
im = Image.open("bg.png")
img = resize(200, 200, im)
img1 = ImageTk.PhotoImage(img)
tkinter.Label(main, image=img1, width=200, height=200).pack()
main.mainloop()
Beispiel #15
0
    'https://www.hockey-reference.com/leagues/NHL_2019_skaters.html')

root = Tk()
root.geometry("645x1000+0+0")
root.title("Hockey Pool")
root.config(background="cyan2")

if site.status_code is 200:
    content = BeautifulSoup(site.content, 'html.parser')
else:
    content = -99

can = Canvas(root, width=615, height=400)
can.grid(row=0, column=0, padx=10, pady=10)
image1 = Image.open("CP.jpg")
photo = ImageTk.PhotoImage(image1)
can.create_image(0, 0, anchor=NW, image=photo)

can.create_oval(450, 150, 500, 200, fill="blue4", outline="#DDD", width=4)
can.create_text(475, 175, text="HP", fill="orangered")

instlab = Label(root, text="Input(Last,First)")
instlab.place(x=517, y=474)

listbox = Listbox(root, width=23, height=20)
listbox.grid(row=1, column=0, sticky=NW, padx=10)
listbox.bind('<<ListboxSelect>>', createlistbox)

listbox2 = Listbox(root, width=23, height=20)
listbox2.place(x=227, y=426)
listbox2.bind('<<ListboxSelect>>', switchPhoto)
Beispiel #16
0
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
    'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4',
    '5', '6', '7', '8', '9', 'dg', 'pd', 'sm', 'ap'
]
# create and position all buttons with a for-loop
# r, c used for row, column grid values
r = 1
c = 0
n = 0
# list(range()) needed for Python3
btn = list(range(len(btn_list)))
for label in btn_list:
    # partial takes care of function and argument
    cmd = partial(click, label)
    # create the button
    path = 'Symbols\\' + label + ".jpg"
    image = Image.open(path)
    photo = ImageTk.PhotoImage(image)
    photos.append(photo)
    btn[n] = tk.Button(lf, text=label, width=50, image=photo, command=cmd)
    # position the button
    btn[n].grid(row=r, column=c)
    # increment button index
    n += 1
    # update row/column position
    c += 1
    if c > 12:
        c = 0
        r += 1
root.mainloop()
Beispiel #17
0
ventana.title("UI para sistemas de control")

# Fetch the service account key JSON file contents
cred = credentials.Certificate('key/key.json')
# Initialize the app with a service account, granting admin privileges
firebase_admin.initialize_app(cred, {
    'databaseURL': 'https://taller-git.firebaseio.com/'
})


marco1 = Frame(ventana, bg="gray", highlightthickness=1, width=1280, height=800, bd= 5)
marco1.place(x = 0,y = 0)
b=Label(marco1,text="")
img = Image.open("D:/Perfil Raul Henao/Desktop/pu/AI")
img = img.resize((150,150), Image.ANTIALIAS)
photoImg=  ImageTk.PhotoImage(img)
b.configure(image=photoImg)
b.place(x = 760,y = 20)

valor= Label(marco1, bg='cadet blue1', font=("Arial Bold", 15), fg="white", width=5)
variable=StringVar()
valor2= Label(marco1, bg='cadet blue1', font=("Arial Bold", 15), fg="white", width=5)
adc_data=StringVar()

def adc_read():
    global prom
    i=0
    prom=0
    while i<15:
        i=i+1
        x=a_0.read()
Beispiel #18
0
    def __init__(self, root):
        self.root = root
        self.root.title("Student Result Management System")
        self.root.geometry("1350x700+0+0")
        self.root.config(bg="white")

        ############# icons
        self.logo_dash = ImageTk.PhotoImage(file="Image/student_icon.png")

        ####################     title  ########################
        title = Label(self.root,
                      text="Student Result Management System",
                      padx=10,
                      compound=LEFT,
                      image=self.logo_dash,
                      font=("goudy old style", 20, "bold"),
                      bg="#033054",
                      fg="white").place(x=0, y=0, relwidth=1, height=50)

        ###############  Menus
        M_Frame = LabelFrame(self.root,
                             text="Menus",
                             font=("times new roman", 15),
                             bg="white")
        M_Frame.place(x=10, y=70, width=1340, height=80)

        btn_course = Button(M_Frame,
                            text="Course",
                            font=("goudy old style", 15, "bold"),
                            bg="#0b5377",
                            fg="white",
                            cursor="hand2",
                            command=self.add_course).place(x=20,
                                                           y=5,
                                                           width=200,
                                                           height=40)
        btn_student = Button(M_Frame,
                             text="Student",
                             font=("goudy old style", 15, "bold"),
                             bg="#0b5377",
                             fg="white",
                             cursor="hand2",
                             command=self.add_student).place(x=240,
                                                             y=5,
                                                             width=200,
                                                             height=40)
        btn_result = Button(M_Frame,
                            text="Result",
                            font=("goudy old style", 15, "bold"),
                            bg="#0b5377",
                            fg="white",
                            cursor="hand2",
                            command=self.add_result).place(x=460,
                                                           y=5,
                                                           width=200,
                                                           height=40)
        btn_view = Button(M_Frame,
                          text="View Student Results",
                          font=("goudy old style", 15, "bold"),
                          bg="#0b5377",
                          fg="white",
                          cursor="hand2",
                          command=self.add_report).place(x=680,
                                                         y=5,
                                                         width=200,
                                                         height=40)
        btn_logout = Button(M_Frame,
                            text="Logout",
                            font=("goudy old style", 15, "bold"),
                            bg="#0b5377",
                            fg="white",
                            cursor="hand2",
                            command=self.logout).place(x=900,
                                                       y=5,
                                                       width=200,
                                                       height=40)
        btn_exit = Button(M_Frame,
                          text="Exit",
                          font=("goudy old style", 15, "bold"),
                          bg="#0b5377",
                          fg="white",
                          cursor="hand2",
                          command=self.exit_).place(x=1120,
                                                    y=5,
                                                    width=200,
                                                    height=40)

        ####################   Content     ###################
        self.bg_img = Image.open("Image/big.jpg")
        self.bg_img = self.bg_img.resize((920, 350), Image.ANTIALIAS)
        self.bg_img = ImageTk.PhotoImage(self.bg_img)

        self.lbl_bg = Label(self.root, image=self.bg_img).place(x=400,
                                                                y=180,
                                                                width=920,
                                                                height=350)

        ##################      update_details     ##############
        self.lbl_course = Label(self.root,
                                text="Total Courses\n[ 0 ]",
                                font=("goudy old style", 20),
                                bd=10,
                                relief=RIDGE,
                                bg="#e43b06",
                                fg="white")
        self.lbl_course.place(x=413, y=530, width=300, height=100)

        self.lbl_student = Label(self.root,
                                 text="Total Students\n[ 0 ]",
                                 font=("goudy old style", 20),
                                 bd=10,
                                 relief=RIDGE,
                                 bg="#0676ad",
                                 fg="white")
        self.lbl_student.place(x=723, y=530, width=300, height=100)

        self.lbl_result = Label(self.root,
                                text="Total Results\n[ 0 ]",
                                font=("goudy old style", 20),
                                bd=10,
                                relief=RIDGE,
                                bg="#038074",
                                fg="white")
        self.lbl_result.place(x=1033, y=530, width=300, height=100)

        ###############     clock
        self.lbl = Label(self.root,
                         text="\nAnalog Clock",
                         font=("Book Antiqua", 25, "bold"),
                         fg="white",
                         compound=BOTTOM,
                         bg="#081923",
                         bd=0)
        self.lbl.place(x=10, y=180, height=450, width=350)
        #self.clock_image()

        ####################     footer  ########################
        footer = Label(
            self.root,
            text=
            "SRM Student Result Management System\nContact us for any Technical Issue: 8939xxxx04",
            font=("goudy old style", 12),
            bg="#262626",
            fg="white").pack(side=BOTTOM, fill=X)
        self.update_details()
def show_Img(file):
    img = Image.open(file)
    img = img.resize((30, 26), Image.ANTIALIAS)
    pic = ImageTk.PhotoImage(img)
    return pic
Beispiel #20
0
def show_rec(filename):
    img = ImageTk.PhotoImage(file=filename)
    Label(root, image=img).grid(row=4, pady=15)
    result = ccn.main(filename)
    Label(root, text=str(result), font=("微软雅黑", 20)).grid(row=5, column=1)
    mainloop()
Beispiel #21
0
from Tkinter import * 
root = Tk()
from PIL import Image, ImageTk
import numpy as np
canvas = Canvas(root, width=500, height=500)
canvas.pack()
# caca = PhotoImage(file='/Users/miquel/raspberry/python/Pantalleta/images/power.png')
# canvas.create_image(250, 250, image=caca)

img= Image.open('images/power3.png')
img= img.resize((100, 100), Image.ANTIALIAS)
img2 = ImageTk.PhotoImage(img)
img.show()

im = img.convert('RGBA')
data1= np.array(im)
data2= np.array(im)
data3= np.array(im)  # "data" is a height x width x 4 numpy array
red, green, blue, alpha = data1.T # Temporarily unpack the bands for readability
red, green, blue, alpha = data2.T # Temporarily unpack the bands for readability
# Replace white with red... (leaves alpha values alone...)
defined_areas = (red == 0) & (blue == 222) & (green == 0)
data1[..., :-1][defined_areas.T] = (0, 0, 0) # Transpose back needed
data2[..., :-1][defined_areas.T] = (0, 255, 0)
data3[..., :-1][defined_areas.T] = (0, 0, 255)

# data1 = Image.fromarray(data1)
# im1=ImageTk.PhotoImage(data1)
# data2 = Image.fromarray(data2)
# im2=ImageTk.PhotoImage(data2)
# data3 = Image.fromarray(data3)
Beispiel #22
0
    )  # update again after 40ms - it should give 25 FPS (1000ms/40ms = 25)


# --- main ---

cap = cv2.VideoCapture(0)

# get first frame to create photo
ret, frame = cap.read()

# - GUI -

root = tk.Tk()

image = Image.fromarray(frame)
photo = ImageTk.PhotoImage(image)  # it has to be after `tk.Tk()`

canvas = tk.Canvas(root, width=photo.width(), height=photo.height())
canvas.pack(fill='both', expand=True)

image_id = canvas.create_image((0, 0), image=photo, anchor='nw')

description = tk.Label(root, text="Place for description")
description.pack()

# - start -

update_frame()  # update it first time

root.mainloop()  # run loop all time - it shows window
Beispiel #23
0
def input_validcode(img):
    root = Tk()

    ret = ''
    closing = False

    def do_step():
        """进行UI事件循环模拟,等待输入,避免使用after系列函数导致的多线程并发崩溃"""
        for i in range(100):
            root.update()
            root.update_idletasks()

    def do_submit(ev=None):
        """记录提交的结果"""
        nonlocal ret
        nonlocal closing
        ret = edt_in.get()
        closing = True

    def do_front():
        """尝试拉取窗口到最前端"""
        fw = root.focus_get()
        if fw != edt_in:
            root.focus_force()
            edt_in.focus_set()

    def do_close(*args, **kwargs):
        """窗口关闭事件"""
        nonlocal closing
        closing = True

    root.protocol('WM_DELETE_WINDOW', do_close)

    # 准备图像对象
    if isinstance(img, bytes):
        img_file = io.BytesIO(img)
    elif isinstance(img, str) and img.startswith('data:image/'):
        data = re.findall(r';base64,(.*)', img)[0]
        imgdata = base64.decodebytes(data.encode('latin-1'))
        img_file = io.BytesIO(imgdata)
    else:
        img_file = Image.open(img)
    img_file = Image.open(img_file)

    # 转换图像对象为标准照片图像,并绑定图片到Label
    img_photo = ImageTk.PhotoImage(img_file)
    img_lbl = Label(root, image=img_photo)
    img_lbl.grid(row=0, column=0)

    # 创建输入框对象
    edt_in = Entry(root,
                   insertbackground='blue',
                   highlightthickness=0,
                   width=20)
    edt_in.grid(row=0, column=1)
    edt_in.bind("<Return>", do_submit)

    # 调整窗口位置,居中
    root.title('输入验证码')
    root.wm_attributes('-topmost', True)  # 窗口置顶
    root.resizable(width=False, height=False)  # 禁止改变窗口大小

    # 处理窗体居中
    root.update()
    screenwidth = root.winfo_screenwidth()
    screenheight = root.winfo_screenheight()
    width = root.winfo_width()
    height = root.winfo_height()
    root.geometry('+%d+%d' % ((screenwidth - width) / 2,
                              (screenheight - height) / 2))
    root.update()

    # 模拟事件主循环,同步进行焦点拉取
    while not closing:
        do_step()
        do_front()
        time.sleep(0.001)

    # 事件循环结束
    root.destroy()

    # 返回最终输入结果
    return ret
    def initUI(self):

        self.parent.title("Configuration Generator")
        self.pack(fill=BOTH, expand=1)

        # --------------- Tabs --------------------------------------
        n = ttk.Notebook(self)
        f1 = Frame(
            n,
            height=window_height - Border_hieht,
            width=window_width - Border_width,
            relief=RAISED,
        )
        # first page, which would get widgets gridded into it
        f2 = Frame(
            n,
            height=window_height - Border_hieht,
            width=window_width - Border_width,
            relief=RAISED,
        )
        # second page
        n.add(f1, text='New Module')
        n.add(f2, text='Modify Old Module')
        n.pack()

        # --------------- Close Button ------------------------------
        closeButton = Button(f1, text="Close")
        closeButton["command"] = self.CloseWindow
        closeButton.place(x=window_width - Border_width - 5,
                          y=window_height - Border_hieht - 5,
                          anchor=SE)
        closeButton2 = Button(f2, text="Close")
        closeButton2["command"] = self.CloseWindow
        closeButton2.place(x=window_width - Border_width - 5,
                           y=window_height - Border_hieht - 5,
                           anchor=SE)

        #---------------- Model Name ---------------------------------
        label = Label(f1, text='ModelName: ')
        label.place(x=10, y=5)
        name = Entry(f1, textvariable=self.modelname, width=15)
        name.place(x=90, y=5)
        label_type = Label(f1, text='Model Type: ')
        label_type.place(x=230, y=5)
        self.type_name = Label(f1, text=self.current_model_type)
        self.type_name.place(x=310, y=5)
        selectModelButton = Button(f1,
                                   text="Select Model Type",
                                   command=self.SelectModelType)
        selectModelButton.place(x=370, y=2)
        defaultButton = Button(f1, text="Default", command=self.SetTypeDefault)
        defaultButton.place(x=506, y=2)

        #--------------- Insert by Connection configuration box ------
        insertByConn = ttk.Labelframe(
            f1,
            text='Insert By Connecting to Existing Models',
            width=580,
            height=240)
        insertByConn.place(x=5, y=30)

        #--------------- Insert by Connection configuration box ------
        insertByPos = ttk.Labelframe(f1,
                                     text='Insert By Position',
                                     width=180,
                                     height=240)
        insertByPos.place(x=590, y=30)

        #---------------- Radio selection -------------------------
        self.Rel_pos = Radiobutton(insertByConn,
                                   text='Connection',
                                   variable=self.InsertMethod,
                                   value='Connection',
                                   command=self.DisableXYZInput)
        self.Abs_pos = Radiobutton(insertByPos,
                                   text='Position',
                                   variable=self.InsertMethod,
                                   value='Position',
                                   command=self.EnableXYZInput)
        self.Abs_pos.select()  # this line doesn't work, haven't figure out why
        self.Rel_pos.place(x=8, y=2)
        self.Abs_pos.place(x=8, y=2)

        #--------------- Connect to -------------------------------
        label2 = Label(insertByConn, text='Connect to:')
        label2.place(x=205, y=5)
        self.connectmodel = ttk.Combobox(insertByConn,
                                         textvariable=self.connectedmodelvar
                                         )  #, command = self.checkConnectivity
        self.connectmodel['values'] = ()
        self.connectmodel.bind('<<ComboboxSelected>>', self.checkConnectivity)
        self.connectmodel.place(x=295, y=5)

        #--------------- Connected face of inserting module -------
        label2 = Label(insertByConn, text='Face of New Module')
        label2.place(x=75, y=35)
        bard = Image.open("SmallSmores.png")
        bardejov = ImageTk.PhotoImage(bard)
        label3 = Label(insertByConn, image=bardejov)
        label3.image = bardejov
        label3.place(x=95, y=90)
        self.Back_face = Radiobutton(insertByConn,
                                     text='Back Face',
                                     variable=self.Node1,
                                     value=3)
        self.left_face = Radiobutton(insertByConn,
                                     text='Left Face',
                                     variable=self.Node1,
                                     value=1)
        self.right_face = Radiobutton(insertByConn,
                                      text='Right Face',
                                      variable=self.Node1,
                                      value=2)
        self.front_face = Radiobutton(insertByConn,
                                      text='Front Face',
                                      variable=self.Node1,
                                      value=0)
        self.front_face.select()
        self.Back_face.place(x=125, y=70, anchor=CENTER)
        self.front_face.place(x=125, y=200, anchor=CENTER)
        self.right_face.place(x=45, y=150, anchor=CENTER)
        self.left_face.place(x=235, y=150, anchor=CENTER)

        #--------------- Connected face of existing module -------
        label4 = Label(insertByConn, text='Face of Existing Module')
        label4.place(x=365, y=35)
        label5 = Label(insertByConn, image=bardejov)
        label5.image = bardejov
        label5.place(x=385, y=90)
        self.Back_face2 = Radiobutton(insertByConn,
                                      text='Back Face',
                                      variable=self.Node2,
                                      value=3)
        self.left_face2 = Radiobutton(insertByConn,
                                      text='Left Face',
                                      variable=self.Node2,
                                      value=1)
        self.right_face2 = Radiobutton(insertByConn,
                                       text='Right Face',
                                       variable=self.Node2,
                                       value=2)
        self.front_face2 = Radiobutton(insertByConn,
                                       text='Front Face',
                                       variable=self.Node2,
                                       value=0)
        self.front_face2.select()
        self.Back_face2.place(x=415, y=70, anchor=CENTER)
        self.front_face2.place(x=415, y=200, anchor=CENTER)
        self.right_face2.place(x=325, y=150, anchor=CENTER)
        self.left_face2.place(x=525, y=150, anchor=CENTER)

        #---------------- Position Entries -------------------------
        label6 = Label(insertByPos, text='X: ')
        label6.place(x=30, y=40)
        self.x_coor = Entry(insertByPos,
                            textvariable=self.X_coor,
                            width=10,
                            state=NORMAL)
        self.x_coor.place(x=30, y=65)

        label7 = Label(insertByPos, text='Y: ')
        label7.place(x=30, y=90)
        self.y_coor = Entry(insertByPos,
                            textvariable=self.Y_coor,
                            width=10,
                            state=NORMAL)
        self.y_coor.place(x=30, y=115)

        label8 = Label(insertByPos, text='Z: ')
        label8.place(x=30, y=140)
        self.Z_coor.set(0.05)
        self.z_coor = Entry(insertByPos,
                            textvariable=self.Z_coor,
                            width=10,
                            state=NORMAL)
        self.z_coor.place(x=30, y=165)

        #--------------- Joint angle and orientation settings ------
        angleInfo = ttk.Labelframe(
            f1,
            text='Joint Angle and Model Orientation Settings',
            width=765,
            height=170)
        angleInfo.place(x=5, y=270)

        #--------------- Joint Angle Setting -----------------------
        label9 = Label(angleInfo, text='Joint Angle Bending ')
        label9.place(x=40, y=10)
        self.Joint3 = Scale(angleInfo,
                            from_=-90,
                            to=90,
                            orient=HORIZONTAL,
                            length=150,
                            resolution=90)
        self.Joint3.place(x=100, y=55, anchor=CENTER)
        label10 = Label(angleInfo, text='Joint Angle Left Wheel ')
        label10.place(x=210, y=10)
        self.Joint1 = Scale(angleInfo,
                            from_=0,
                            to=360,
                            orient=HORIZONTAL,
                            length=150,
                            resolution=90)
        self.Joint1.place(x=280, y=55, anchor=CENTER)

        label11 = Label(angleInfo, text='Joint Angle Right Wheel ')
        label11.place(x=30, y=80)
        self.Joint2 = Scale(angleInfo,
                            from_=0,
                            to=360,
                            orient=HORIZONTAL,
                            length=150,
                            resolution=90)
        self.Joint2.place(x=100, y=125, anchor=CENTER)
        label12 = Label(angleInfo, text='Joint Angle Front Wheel ')
        label12.place(x=210, y=80)
        self.Joint0 = Scale(angleInfo,
                            from_=0,
                            to=360,
                            orient=HORIZONTAL,
                            length=150,
                            resolution=90)
        self.Joint0.place(x=280, y=125, anchor=CENTER)

        #--------------- Face Displacement ------------------------
        label13 = Label(angleInfo, text='Distance offset ')
        label13.place(x=380, y=10)
        doffset = Entry(angleInfo, textvariable=self.C_dis, width=10)
        doffset.place(x=380, y=40)

        label14 = Label(angleInfo, text='Angle offset')
        label14.place(x=380, y=80)
        # self.aoffset = Entry(angleInfo, textvariable=self.a_dis,width=10)
        self.aoffset = Scale(angleInfo,
                             from_=-180,
                             to=180,
                             orient=HORIZONTAL,
                             length=100,
                             resolution=90,
                             state=DISABLED)
        self.aoffset.place(x=380, y=105)

        #--------------- Model Orientation ------------------------
        label15 = Label(angleInfo, text='Model Orientation ')
        label15.place(x=610, y=10)

        label16 = Label(angleInfo, text='Row ')
        label16.place(x=560, y=45)
        self.row = Scale(angleInfo,
                         from_=0,
                         to=360,
                         orient=HORIZONTAL,
                         length=100,
                         resolution=90)
        self.row.place(x=660, y=45, anchor=CENTER)
        label17 = Label(angleInfo, text='Pitch ')
        label17.place(x=560, y=85)
        self.pitch = Scale(angleInfo,
                           from_=0,
                           to=360,
                           orient=HORIZONTAL,
                           length=100,
                           resolution=90)
        self.pitch.place(x=660, y=85, anchor=CENTER)
        label18 = Label(angleInfo, text='Yaw ')
        label18.place(x=560, y=125)
        self.yaw = Scale(angleInfo,
                         from_=0,
                         to=360,
                         orient=HORIZONTAL,
                         length=100,
                         resolution=90)
        self.yaw.place(x=660, y=125, anchor=CENTER)

        #-------------- Select Model -----------------------------
        label19 = Label(f2, text='Select Model ')
        label19.place(x=10, y=10)
        self.modelselect = ttk.Combobox(f2, textvariable=self.modellist)
        self.modelselect['values'] = ()
        self.modelselect.bind('<<ComboboxSelected>>', self.CheckJointAngle)
        self.modelselect.place(x=95, y=10)

        #---------------- Joint Angle Setting -------------------
        lf = ttk.Labelframe(f2,
                            text='Joint Angle Modification ',
                            width=350,
                            height=180)
        lf.place(x=10, y=50)
        label20 = Label(lf, text='Joint Angle Bending ')
        label20.place(x=20, y=10)
        self.Joint_3 = Scale(lf,
                             from_=-90,
                             to=90,
                             orient=HORIZONTAL,
                             length=150,
                             resolution=5,
                             command=self.ChangeJointAngle)
        self.Joint_3.bind('<ButtonRelease-1>', self.FindConnectable)
        self.Joint_3.place(x=80, y=50, anchor=CENTER)
        label21 = Label(lf, text='Joint Angle Left Wheel ')
        label21.place(x=190, y=10)
        self.Joint_1 = Scale(lf,
                             from_=0,
                             to=360,
                             orient=HORIZONTAL,
                             length=150,
                             resolution=5,
                             command=self.ChangeJointAngle)
        self.Joint_1.bind('<ButtonRelease-1>', self.FindConnectable)
        self.Joint_1.place(x=260, y=50, anchor=CENTER)

        label22 = Label(lf, text='Joint Angle Right Wheel ')
        label22.place(x=20, y=80)
        self.Joint_2 = Scale(lf,
                             from_=0,
                             to=360,
                             orient=HORIZONTAL,
                             length=150,
                             resolution=5,
                             command=self.ChangeJointAngle)
        self.Joint_2.bind('<ButtonRelease-1>', self.FindConnectable)
        self.Joint_2.place(x=80, y=120, anchor=CENTER)
        label23 = Label(lf, text='Joint Angle Front Wheel ')
        label23.place(x=190, y=80)
        self.Joint_0 = Scale(lf,
                             from_=0,
                             to=360,
                             orient=HORIZONTAL,
                             length=150,
                             resolution=5,
                             command=self.ChangeJointAngle)
        self.Joint_0.bind('<ButtonRelease-1>', self.FindConnectable)
        self.Joint_0.place(x=260, y=120, anchor=CENTER)

        #---------------- Delete Model ----------------------------
        self.DeleteButton = Button(f2,
                                   text="Delete",
                                   command=self.DeleteModule)
        self.DeleteButton["state"] = DISABLED
        self.DeleteButton["fg"] = "red"
        self.DeleteButton.place(x=5,
                                y=window_height - Border_hieht - 5,
                                anchor=SW)

        #---------------- Add More Connections --------------------
        more_conn = ttk.Labelframe(f2,
                                   text='Add More Connections ',
                                   width=350,
                                   height=140)
        more_conn.place(x=400, y=50)

        label24 = Label(more_conn, text='Select Possible Connection ')
        label24.place(x=10, y=10)
        self.nodeselect = ttk.Combobox(more_conn,
                                       textvariable=self.adjacentnode,
                                       width=38)
        self.nodeselect['values'] = ()
        self.nodeselect.bind('<<ComboboxSelected>>',
                             self.EnableAddNewConnection)
        self.nodeselect.place(x=10, y=40)

        self.ConnectButton = Button(more_conn, text="Connect")
        self.ConnectButton["command"] = self.AddNewConnection
        self.ConnectButton.place(x=260, y=80)

        #---------------- Delete Whole Configuration -----------------
        del_conf = ttk.Labelframe(f2,
                                  text='Delete Entire Configuration ',
                                  width=350,
                                  height=50)
        del_conf.place(x=400, y=200)

        self.del_conf_confirm = Checkbutton(del_conf,
                                            text="Please confirm",
                                            variable=self.del_confirm,
                                            onvalue=1,
                                            offvalue=0,
                                            command=self.ConfirmCheck,
                                            state=DISABLED)
        self.del_conf_confirm.place(x=10, y=5)

        self.DeleteConfigButton = Button(del_conf,
                                         text="delete",
                                         width='16',
                                         command=self.DeleteConfiguration,
                                         state=DISABLED)
        self.DeleteConfigButton.place(x=180, y=0)

        #---------------- Insert Model -------------------------------
        InsertButton = Button(f1, text="Insert")
        InsertButton["command"] = self.InsertModel
        InsertButton.place(x=5, y=window_height - Border_hieht - 5, anchor=SW)

        #---------------- Save Button --------------------------------
        # savepathlabel = Label(f1, text='Save path: ')
        # savepathlabel.place(x = window_width-Border_width-475, y = window_height-Border_hieht-7, anchor = SE)
        # savepathlabel2 = Label(f2, text='Save path: ')
        # savepathlabel2.place(x = window_width-Border_width-475, y = window_height-Border_hieht-7, anchor = SE)
        # self.savepathstr.set("~/.gazebo/models/SMORES7Stella/");
        # self.savepath1 = Entry(f1, textvariable=self.savepathstr, width = 35)
        # self.savepath1.place(x = window_width-Border_width-190, y = window_height-Border_hieht-7, anchor = SE)
        # self.savepath2 = Entry(f2, textvariable=self.savepathstr, width = 35)
        # self.savepath2.place(x = window_width-Border_width-190, y = window_height-Border_hieht-7, anchor = SE)
        self.saveButton = Button(f1, text="Save", command=self.WriteFile)
        self.saveButton.place(x=window_width - Border_width - 125,
                              y=window_height - Border_hieht - 5,
                              anchor=SE)
        self.saveButton2 = Button(f2, text="Save", command=self.WriteFile)
        self.saveButton2.place(x=window_width - Border_width - 125,
                               y=window_height - Border_hieht - 5,
                               anchor=SE)

        self.loadButton = Button(f1, text="Load", command=self.LoadFile)
        self.loadButton.place(x=window_width - Border_width - 65,
                              y=window_height - Border_hieht - 5,
                              anchor=SE)
        self.loadButton2 = Button(f2, text="Load", command=self.LoadFile)
        self.loadButton2.place(x=window_width - Border_width - 65,
                               y=window_height - Border_hieht - 5,
                               anchor=SE)
# Size of bitmap image
width = 128
height = (len(data) // width) + 1
num_images = (len(data) // (width * width)) + 1
current_position = 0

# Set canvas resizable
root.grid_rowconfigure(0, weight=1)
root.grid_columnconfigure(0, weight=1)

# labels for legends
label_image1 = Image.new(mode="RGB", size=(12, 12))
label_draw1 = ImageDraw.Draw(label_image1)
label_draw1.rectangle((0, 0, 11, 11), fill=color_dict["white"], outline=color_dict["black"])
label_imagetk1 = ImageTk.PhotoImage(image=label_image1)
label1 = tkinter.Label(text=" 0x00", image=label_imagetk1, compound="left", height=12)
label1.grid(row=1, column=0, padx=0, pady=0, sticky="w", columnspan=2)

label_image2 = Image.new(mode="RGB", size=(12, 12))
label_draw2 = ImageDraw.Draw(label_image2)
label_draw2.rectangle((0, 0, 12, 12), fill=color_dict["blue"], outline=color_dict["blue"])
label_imagetk2 = ImageTk.PhotoImage(image=label_image2)
label2 = tkinter.Label(text=" ASCII control", image=label_imagetk2, compound="left", height=12)
label2.grid(row=2, column=0, padx=0, pady=0, sticky="w", columnspan=2)

label_image3 = Image.new(mode="RGB", size=(12, 12))
label_draw3 = ImageDraw.Draw(label_image3)
label_draw3.rectangle((0, 0, 12, 12), fill=color_dict["red"], outline=color_dict["red"])
label_imagetk3 = ImageTk.PhotoImage(image=label_image3)
label3 = tkinter.Label(text=" ASCII printable", image=label_imagetk3, compound="left", height=12)
Beispiel #26
0
def create_fileselect():
    global dirVar
    global sortedDir
    global globalflag
    sortedDir = filedialog.askdirectory(initialdir=os.path.dirname(dirVar))
    fileselect_window = Toplevel(window)
    fileselect_window.geometry("900x600")
    fileselect_window.resizable(width=False, height=False)

    filelisting = Listbox(fileselect_window,
                          height=36,
                          width=40,
                          selectmode=SINGLE)
    filelisting.place(anchor=W, relx=0.02, rely=0.5)
    for i in listdir(sortedDir):
        if i.endswith("png") or i.endswith("jpg") or i.endswith("jpeg"):
            filelisting.insert(END, i)
    if filelisting.size() == 0:
        messagebox.showerror(
            "Folder Empty",
            "Folder GUHProject is empty.\nPlease add images into the folder.")
        fileselect_window.destroy()
    imagelabelframe = Frame(fileselect_window,
                            width=620,
                            height=550,
                            bd=2,
                            relief=SUNKEN)
    imagelabelframe.pack_propagate(False)
    imagelabel = Label(imagelabelframe, anchor=CENTER)
    imagelabelframe.place(relx=0.99, rely=0.015, anchor=NE)
    imagelabel.place(relx=0.5, rely=0.5, anchor=CENTER)
    fix = Button(fileselect_window,
                 text="Fix",
                 width=8,
                 height=1,
                 bd=2,
                 command=fix_folder)
    fix.place(relx=0.99, rely=0.99, anchor=SE)
    currentindex = []
    while globalflag:
        selectedfileindex = list(filelisting.curselection())
        fileselect_window.update()
        if selectedfileindex == currentindex:
            continue
        elif selectedfileindex != []:
            global selectedfile
            selectedfile = filelisting.get(selectedfileindex)
            print(selectedfile)
            selectedimage = cv2.imread(sortedDir + "/" + selectedfile)
            b, g, r = cv2.split(selectedimage)
            imagergb = cv2.merge((r, g, b))
            imagergb_obj = Image.fromarray(imagergb)
            x = imagergb_obj.size[0]
            y = imagergb_obj.size[1]
            ratio = min(600 / x,
                        530 / y)  #620x550, slightly smaller to fit frame
            if x > 600 or y > 530:
                x = int(x * ratio)
                y = int(y * ratio)
            imagergb_obj = imagergb_obj.resize((x, y), Image.ANTIALIAS)
            imagergb_tk = ImageTk.PhotoImage(image=imagergb_obj)
            imagelabel.configure(image=imagergb_tk)
            currentindex = selectedfileindex
    fileselect_window.destroy()
    globalflag = True
import tkinter as tk
from tkinter import *
import pyttsx3
import tkinter.font as tkFont
from PIL import Image, ImageTk

engine = pyttsx3.init()

window = tk.Tk()
window.resizable(width=False, height=False)
window.geometry("600x300")
window.title("Minor Project by Apoorv")


load = Image.open("logo.png")
render = ImageTk.PhotoImage(load)
img = Label(image=render)
img.image = render
img.place(relx=0.25,rely=0.02)

written = StringVar()

def speak():
    to_say = str(written.get())
    if len(to_say)>0: 
        engine.say(to_say)
        engine.runAndWait()   

Label(window,text="What to say : ",font=tkFont.Font(family="Lucida Grande", size=10)).place(relx=0.3,rely=0.5,anchor=tk.CENTER)
Entry(window,textvariable=written,width=30).place(relx=0.6,rely=0.5,anchor=tk.CENTER)
Button(window,text = "SPEAK !!",command = speak,width=20,height=2).place(relx=0.5,rely=0.8,anchor=tk.CENTER)
from tkinter import *
from PIL import ImageTk, Image


base = Tk()


#Loading images and generating photo objects
image1 = Image. open("botpic.jpg")
image1 = image1.resize((25, 25), Image. ANTIALIAS)
image2 = Image. open("user-24.gif")
image2 = image2.resize((25, 25), Image. ANTIALIAS)
botimg = ImageTk.PhotoImage(image1)
userimg = ImageTk.PhotoImage(image2)

#Changing window image
base.tk.call('wm', 'iconphoto', base._w,botimg )
base.title("Anime Bot")
base.geometry("400x500")
base.resizable(width=TRUE, height=TRUE)

#Chat Window
ChatLog = Text(base, bd=2,relief = "ridge", bg="beige", height="100", width="50", font="Arial")
ChatLog.config(state=NORMAL)

#Send Button
SendButton = Button(base, font=("Verdana",12,'bold','italic'), text="Send", width="12", height=5,
                    bd=0, bg="#030bfc", activebackground="#7373ff",fg='#ffffff',
                    command= send )
RecentButton = Button(base, font=("Verdana",12,'bold','italic'), text="Recent", width="12", height=5,
                    bd=0, bg="#030bfc", activebackground="#7373ff",fg='#ffffff',
    def __init__(self, protocol):
        self.user = None
        self.protocol = protocol

        # window configuration
        self.window = tk.Tk()
        self.window.title(servconst.APP_NAME)
        self.window.resizable(False, False)
        winWidth = 500
        winHeight = 500
        xPos = self.window.winfo_screenwidth() / 2 - winWidth / 2
        yPos = self.window.winfo_screenheight() / 2 - winHeight / 2
        self.window.geometry('{}x{}+{}+{}'.format(winWidth, winHeight, xPos,
                                                  yPos))

        # logo
        logo = ImageTk.PhotoImage(Image.open('resources/logo.png'))
        logoLab = tk.Label(self.window, image=logo)
        logoLab.grid(row=0, columnspan=2, padx=(20, 20), pady=(10, 60))

        # name field
        clientNameLab = tk.Label(self.window,
                                 text='name:',
                                 font=('Futura-Light', 18))
        clientNameLab.grid(row=1,
                           column=0,
                           sticky=tk.E,
                           padx=(10, 10),
                           pady=(10, 10))

        self.nameBuffer = tk.StringVar()
        nameField = tk.Entry(self.window, textvariable=self.nameBuffer)
        nameField.grid(row=1,
                       column=1,
                       sticky=tk.W,
                       padx=(10, 10),
                       pady=(10, 10),
                       ipady=3)

        # chat title field
        chatTitleLab = tk.Label(self.window,
                                text='chat title:',
                                font=('Futura-Light', 18))
        chatTitleLab.grid(row=2,
                          column=0,
                          sticky=tk.E,
                          padx=(10, 10),
                          pady=(10, 10))

        self.chatTitleBuffer = tk.StringVar()
        chatTitleField = tk.Entry(self.window,
                                  textvariable=self.chatTitleBuffer)
        chatTitleField.grid(row=2,
                            column=1,
                            sticky=tk.W,
                            padx=(10, 10),
                            pady=(10, 10),
                            ipady=3)

        # enter button
        buttonImage = ImageTk.PhotoImage(
            Image.open('resources/enter_button.png'))
        enterButton = tk.Button(self.window, command=self.enter)
        enterButton.config(image=buttonImage, highlightthickness=0, bd=0)
        enterButton.grid(row=3, columnspan=2, pady=(40, 20))

        # receiveThread = Thread(target=self.receive)
        # receiveThread.start()
        self.window.mainloop()
Beispiel #30
0
from tkinter import *
from PIL import ImageTk, Image
import os

#* Navigating to the image directory
BASE_DIR = os.path.dirname(__file__)
IMAGE_DIR = os.path.join(BASE_DIR, 'Images')

#* Setting up the tkinter window
root = Tk()
root.title("Image Viewer")

#* Getting image image_list
img1 = ImageTk.PhotoImage(Image.open(os.path.join(IMAGE_DIR, 'aurora.jpg')))
img2 = ImageTk.PhotoImage(Image.open(os.path.join(IMAGE_DIR, 'galaxy.jpg')))
img3 = ImageTk.PhotoImage(Image.open(os.path.join(IMAGE_DIR, 'igloo.jpg')))
img4 = ImageTk.PhotoImage(Image.open(os.path.join(IMAGE_DIR, 'island.jpg')))
img5 = ImageTk.PhotoImage(Image.open(os.path.join(IMAGE_DIR, 'sunset.jpg')))
image_list = [img1, img2, img3, img4, img5]

#* Default Image
ind = 0
img_label = Label(root, image=image_list[ind])
img_label.grid(row=0, column=0, columnspan=3)

#? Functions
def next_():
    global image_list, img_label, ind, next_button
    
    ind += 1
    img_label.grid_forget()