Ejemplo n.º 1
0
def getFilePathViaGUI(window_title: str = '') -> str:
    """ Display an "Open" dialog box and return the path to a selected file """
    window = tk()
    window.withdraw()
    window.lift()
    window.overrideredirect(True)
    window.call('wm', 'attributes', '.', '-topmost', True)
    return askopenfilename(initialdir='./', title=window_title)
Ejemplo n.º 2
0
def getDirPathViaGUI(window_title: str = '') -> str:
    # show an "Open" dialog box and return the path to the selected dir
    window = tk()
    window.withdraw()
    window.lift()
    window.overrideredirect(True)
    window.call('wm', 'attributes', '.', '-topmost', True)
    return askdirectory(initialdir='./', title=window_title)
 def setname(self):
     txt = tkinter.tk()
     v = stringvar()
     e1 = entry(txt, bd=5, textvariable = v)
     e1.grid()
     e1.focus_set()
     def setclus():
         self.clustername = e1.get()
         file = open("info.txt", "a")
         #the cluster name line begins with an n as an identifier
         file.write("n" + self.clustername + "\n")
         file.close()
         txt.destroy()
     button = button(txt, text="set name", width=10, command=setclus)
     button.grid()
     txt.mainloop()
 def __init_gui(self):
     self.max_port = max_port
     self.min_port = min_port
     window = tkinter.tk() 
     window.title("Port Scanner") 
     window.geometry("300x300") 
     window.mainloop()
     lbl1 = tkinter.Label(window, text = 'Host IP')
     lbl1.grid(row = 1, column = 1)
     ent1 = tkinter.Entry(window)
     ent1.grid(row = 1, column = 2)
     lbl2 = tkinter.Label(window, text = 'Host Name')
     lbl2.grid(row = 2, column = 1)
     lbl3 = tkinter.Label(window, )
     lbl3.grid(row = 3, column = 1)
     def populate_label(label)
Ejemplo n.º 5
0
def button_1_click():
    """Button to enter 'hello' in widget named label1."""
    #print(len(mainframe.winfo_children())) #3 label and 2 x buttons
    for child in mainframe.winfo_children(): 
        if child.winfo_name() == "label1":
            child.configure(text="hello")        

def button_2_click():
    """Button to clear the contents of the widget named label1."""
    for child in mainframe.winfo_children(): 
        if child.winfo_name() == "label1":
            child.configure(text="") 

# Instantiate tkinter.Tk() as the object "root".    
root = tk()
root.title("Hello")
# Instantiate the Windows frame as "mainframe" so widgets can be added
mainframe = ttk.Frame(root)
mainframe.pack()

# Add widgets. A label and two buttons
ttk.Label(mainframe, 
          text="Press a button", 
          name="label1",
          font="FreeSans, 14").pack(pady=10)
ttk.Button(mainframe, text="Hello", command=button_1_click).pack(padx=50)
ttk.Button(mainframe, text="Clear", command=button_2_click).pack(padx=50)

# For additional padding of widgets from their frame borders
#for child in mainframe.winfo_children(): 
Ejemplo n.º 6
0
    def __init__(self):
        """The 'Main'-Layer is the .window"""
        GUI_DennTris.instance_counter += 1
        self.root = tkinter.tk()
        #self.root.resizable(width=False, height=False)
        self.root.title('DennTris')
        init_x = (self.root.winfo_screenwidth() - SCR_WIDTH) / 2
        init_y = (self.root.winfo_screenheight() - SCR_HEIGHT) / 2
        self.root.geometry('%dx%d+%d+%d' %
                           (SCR_WIDTH, SCR_HEIGHT, init_x, init_y))
        self.root.bind_all('<Escape>', lambda event: event.widget.quit())

        global SCR_WIDTH_ACT
        global SCR_HEIGHT_ACT
        global SCR_SIZE_ACT
        SCR_WIDTH_ACT = self.root.winfo_screenwidth()
        SCR_HEIGHT_ACT = self.root.winfo_screenheight()
        SCR_SIZE_ACT = (SCR_WIDTH_ACT, SCR_HEIGHT_ACT)
        print(SCR_SIZE_ACT)

        self.__init_full_screen_capability()

        self.window_back = tkinter.Canvas(self.root,
                                          width=SCR_WIDTH_ACT,
                                          height=SCR_HEIGHT_ACT,
                                          background='black',
                                          highlightthickness=0)
        self.window_back.place(in_=self.root,
                               relx=0.5,
                               rely=0.5,
                               anchor=tkinter.CENTER)

        self.window = tkinter.Canvas(self.window_back,
                                     width=SCR_WIDTH,
                                     height=SCR_HEIGHT,
                                     background='black',
                                     highlightthickness=0)
        #self.window.pack()
        self.window.place(in_=self.window_back,
                          relx=0.5,
                          rely=0.5,
                          anchor=tkinter.CENTER)

        self.__block0_disp = Canvas(self.window,
                                    width=BLOCK_WIDTH,
                                    height=BLOCK_HEIGHT,
                                    highlightthickness=0)
        self.__block0_disp.place(x=0, y=0)
        self.__block1_disp = Canvas(self.window,
                                    width=BLOCK_WIDTH,
                                    height=BLOCK_HEIGHT,
                                    highlightthickness=0)
        self.__block1_disp.place(in_=self.__block0_disp,
                                 relx=1,
                                 y=0,
                                 bordermode="outside")
        self.__block2_disp = Canvas(self.window,
                                    width=BLOCK_WIDTH,
                                    height=BLOCK_HEIGHT,
                                    highlightthickness=0)
        self.__block2_disp.place(in_=self.__block1_disp,
                                 relx=1,
                                 y=0,
                                 bordermode="outside")
        self.__block3_disp = Canvas(self.window,
                                    width=BLOCK_WIDTH,
                                    height=BLOCK_HEIGHT,
                                    highlightthickness=0)
        self.__block3_disp.place(in_=self.__block2_disp,
                                 relx=1,
                                 y=0,
                                 bordermode="outside")
        self._blocks_disp = (self.__block0_disp, self.__block1_disp,
                             self.__block2_disp, self.__block3_disp)

        for idx, block_obj in enumerate(self._blocks_disp, start=0):
            self.draw_absent_block(block_obj, idx)
#         self.update_block_display()

        self.quitbutton = tkinter.Button(self.window,
                                         text="QUIT",
                                         fg="red",
                                         command=self.root.quit)
        self.quitbutton.place(in_=self.__block3_disp,
                              relx=0.5,
                              rely=1,
                              y=10,
                              bordermode="outside",
                              anchor=tkinter.N,
                              width=0.75 * BLOCK_WIDTH,
                              height=0.75 * BLOCK_HEIGHT)
        '''
        self.t_btn_1_state = 0
        toggle1button = tkinter.Button(self.window,text="Toggle1", bg='gray', fg="green", relief="raised", command=lambda:self.toggle_block_and_button(self.__block1_disp,1))
        toggle1button.place(in_=self.__block1_disp, relx=0.5, rely=1, y=10, bordermode="outside",anchor=tkinter.N, width=0.75*BLOCK_WIDTH, height=0.75*BLOCK_HEIGHT)
        '''

        self.console_frame_without_border = tkinter.Frame(
            self.window,
            width=SCR_WIDTH,
            height=int(0.3 * SCR_HEIGHT) + 3,
            bg='black')
        self.console_frame_without_border.place(x=0,
                                                y=int(0.7 * SCR_HEIGHT) - 3)
        self.console_frame_border = Canvas(self.console_frame_without_border,
                                           highlightthickness=0,
                                           width=SCR_WIDTH,
                                           height=3,
                                           bg='gray')
        self.console_frame_border.place(in_=self.console_frame_without_border)
        #         self.temp.create_line(0,0,SCR_WIDTH,0,fill='red',width=3)
        self.console_frame = tkinter.Frame(self.console_frame_without_border,
                                           width=SCR_WIDTH,
                                           height=int(0.3 * SCR_HEIGHT),
                                           bg='black')
        self.console_frame.place(in_=self.console_frame_without_border, y=3)

        self.console_output = tkinter.Text(self.console_frame,
                                           bg='black',
                                           fg='white',
                                           font=("Times", 11),
                                           highlightthickness=0,
                                           highlightbackground='black',
                                           pady=0,
                                           padx=0)
        self.console_output_scrollbar = tkinter.Scrollbar(
            self.console_frame,
            orient="vertical",
            command=self.console_output.yview)
        self.root.update()
        self.console_output_scrollbar.place(
            in_=self.console_frame,
            height=self.console_frame.winfo_height(),
            anchor=tkinter.NE,
            relx=1)
        self.console_output.config(
            yscrollcommand=self.console_output_scrollbar.set)
        self.root.update()
        self.console_output.place(
            in_=self.console_frame,
            height=int(0.3 * SCR_HEIGHT),
            width=(SCR_WIDTH - self.console_output_scrollbar.winfo_width()))
        self.console_output.configure(state=tkinter.DISABLED)
        #         self.console_output_scrollbar.configure(command=self.console_output.yview)
        self.console_output.see("end")

        # make sure the widget gets focus when clicked
        # on, to enable highlighting and copying to the
        # clipboard.
        self.console_output.bind("<1>",
                                 lambda event: self.console_output.focus_set())
    for downRepetition in range(0, repetition):
        time.sleep(.3)
        g.press(['down'])

    g.press('enter')
    _myPyFunc.getCoordinatesWhenImageAppears('accountFound.png')

    time.sleep(3)
    if g.locateOnScreen('saveChanges.png'):
        p('saveChanges found.')
        g.hotkey('alt', 's')

    _myPyFunc.waitUntilImageDisappears('saveChanges.png')

    g.hotkey('ctrl', 'c')

    g.press(['tab'] * 2)

    inactivatedCoordinates = None

    while not inactivatedCoordinates:
        g.press('space')
        time.sleep(2)
        p('Looking for inactivated box checked...')
        inactivatedCoordinates = g.locateCenterOnScreen(
            'inactiveBoxInactivated.png')

    p(f'{repetition} is complete. Account description: ' +
      tk().clipboard_get())
Ejemplo n.º 8
0
from tkinter import Tk as tk
from tkinter.filedialog import askopenfilename
from xmlrpc.client import ServerProxy, Binary
import os
import datetime

proxy = ServerProxy("http://localhost:5000/")

tk().withdraw()
file_name = askopenfilename()
print(file_name)

dt = os.stat(file_name).st_ctime
time = datetime.date.fromtimestamp(dt).strftime('%d-%m-%Y')
print(time)

file =  open(file_name, 'rb')
bin_data = Binary(file.read())
proxy.data_transfer(bin_data, file_name, dt)
Ejemplo n.º 9
0
    def __init__(self, parent=None):
        self.root = tk()
        root = self.root
        self.parent = parent
        Frame.__init__(self)
        top_frame = Frame(root)
        bottom = Frame(root)
        box_frame = Frame(top_frame)
        label_frame = Frame(box_frame)
        input_frame = Frame(box_frame)
        bottom.pack(side=BOTTOM, fill=BOTH, expand=True)
        # Packings
        top_frame.pack(side=TOP)
        bottom.pack(side=BOTTOM, fill=BOTH, expand=True)
        box_frame.pack(side=LEFT)
        label_frame.pack(side=TOP)
        input_frame.pack(side=BOTTOM)

        # create the widgets for the top part of the GUI,
        # and lay them out
        self.ticker_field = Text(top_frame, width=5, height=1)
        self.time_range = Text(top_frame, width=2, height=1)
        ticker_label = Label(top_frame, text="Ticker:", width=5, height=1)
        time_label = Label(top_frame, text="Hrs", width=2, height=1)

        button1 = Button(root,
                         text="Recent Posts",
                         width=10,
                         height=2,
                         command=self.recent_posts)
        button3 = Button(root,
                         text="Summary",
                         width=10,
                         height=2,
                         command=self.trending_posts)
        button2 = Button(root,
                         text="All Posts",
                         width=10,
                         height=2,
                         command=self.all_posts)
        button4 = Button(root,
                         text="Open Url",
                         width=10,
                         height=2,
                         command=self.open_url)

        button1.pack(in_=top_frame, side=LEFT)
        button3.pack(in_=top_frame, side=LEFT)
        button2.pack(in_=top_frame, side=LEFT)
        button4.pack(in_=top_frame, side=LEFT)

        ticker_label.pack(in_=label_frame, side=LEFT)
        time_label.pack(in_=label_frame, side=LEFT)
        self.ticker_field.pack(in_=input_frame, side=LEFT)
        self.time_range.pack(in_=input_frame, side=LEFT)
        self.main = self.master
        self.main.geometry('1200x800+200+100')
        self.main.title('Table app')

        # btn2 = Button(self.root, text="Ticker Post History", command=self.button2)
        # btn2.pack()
        # urlbtn = Button(self.root, text="Open url", command=self.open_url)
        # urlbtn.pack()

        self.f = Frame(self.main)
        self.f.pack(fill=BOTH, expand=1)
        # df = panda_db.get_trending()
        df = panda_db.get_all_posts("8")
        # df = panda_db.get_posts_by_ticker("AI")

        self.table = Table(self.f,
                           dataframe=df,
                           showtoolbar=True,
                           showstatusbar=True)

        self.table.show()

        return
Ejemplo n.º 10
0
        counter += 1
        label.config (text=str (counter))
        label.after(1000, count), count ()

phone = input("phone: ")
digits_mapping{
    "0" = "one"
    "1" = "one"
    "2" = "two"
    "3" = "three"
}
output = ""
for ch in phone:
output += digits_mapping.get (ch, "!") + " "
print(output)

        root = tk.tk ()
        root.title("counting seconds")
        lable = tk.lable
        (root,
        fg ="dark green")
        label.park()counter_lable
        (lable)button = tk.button
        (root, text = 'stop',
        width = 25,
        command = root.destroy)
        button.pack()root.mainLoop()



Ejemplo n.º 11
0
 def __init__(self, text, pdx, pdy):
     root = tk.tk()
     label = tk.Label(root, text=text, pdx=pdx, pdy=pdy)
     label.mainloop()
Ejemplo n.º 12
0
TODO:
- setup.py
- Implement proper Preprocessing
- implement multithreading
'''

#Local Imports
from Midend import midend
from Backend import delete_temp
#External Imports
from tkinter import Tk as tk, Menu, Frame, Button, filedialog as fd, Listbox, Toplevel, ttk, Label
from os import startfile

#Construct main window as global
main = tk()
main.title("Text2Podcast by Christoferis V1.0")
main.geometry("1280x720")


#Main Open class
class File:
    #External accesed vars
    sourcepaths = dict()

    def __init__(self, listbox):
        #var
        self.listbox = listbox
        self.listbox.insert(
            "end", "Welcome to Text2Podcast! Start by Importing some Files")
Ejemplo n.º 13
0
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 19 14:14:17 2020

@author: ryanl
"""
import tkinter as tk
window=tk.tk()
window.title("menu")
window.geometry("500*500)
menubar=tk.Menu(window)

filemeun.tk.Meun(menuBar,tearoff=False)
filemeun.add_command(label="開始遊戲")


filemeun.add_command(label="作弊指令")

filemeun.add_separator()



filemeun.add_command(label="Zxit")
menuBar.add_cascade

filemeun2.add_command(label="遊戲設定")

filemeun2.add_command(label="畫面設定")
Ejemplo n.º 14
0
    print("player is out")


def not_out():
    thread =threading.Thred(target=pending,args=("not out",))
    thread.daemon=1
    thread.start() 
    print("player is not out")


#width and hieght of our main screen

SET_WIDTH= 650
SET_HEIGHT=368
#Tkinter gui starts here
window=tkinter.tk()
window.title("third umpire decision")
cv_img=cv2.cvtColor(cv2.imread("welcome.png"),cv2.COLOR_BGR2RGB)
canvas= tkinter.Canvas(window,width=SET_WIDTH,height=SET_HEIGHT)

photo=PIL.ImageTk.PhotoImage(image=PIL.Image.fromarray(cv_img))
image_on_canvas=canvas.creat_image(0,0,ancho=tkinter.NM,image=photo)
canvas.pack()

#buttons to control playback
btn=tkinter.Button(window,text="<< previous (fast)",width=50,command=partial(play,-25))
btn.pack()

btn=tkinter.Button(window,text="<< previous (slow)",width=50,command=partial(play,-2))
btn.pack()
Ejemplo n.º 15
0
import tkinter
import urllib.request

def left(event):
    print("left")

def right(event):
    print("right")

main = tkinter.tk()


frame = Frame(main, width=100, height=100)
main.bind('<Left>',left)
main.bind('<Right>',right)
frame.pack()
main.mainloop()