from pytube import YouTube
from PIL import ImageTk, Image
import requests
import urllib.parse
import io
import time
from tkinter import filedialog
import os
import threading


root = ThemedTk(theme="radiance")
root.title("Youtbe video downloader")
root.geometry('670x340')
root.maxsize(670, 340)
root.minsize(670, 340)
root.iconbitmap('images/youtube-downloader.ico')
root.configure(bg='#100E17')

text = tk.Label(root, text="Download Video and Audio from YouTube",
                font='Helvetica 15 bold', bg="#100E17", fg="white")
text.pack()

status = tk.Label(root, text="Status bar", font='Helvetica 10',
                  relief='sunken', anchor="w",bg="#312D3C",fg="white")
status.pack(side="bottom", fill='x')

# Creating threads


def threadButtonOne():
Exemplo n.º 2
0
from tkinter import *
from tkinter import ttk
from ttkthemes import ThemedTk
import pandas as pd
import os
from tkinter.filedialog import askopenfile, asksaveasfilename

win = ThemedTk(theme="aqua")
win.title("Notepad")
win.geometry("720x480")
win.minsize(720, 480)
win.config(background='#272C35')


def open_file():
    blank.delete("1.0", END)
    file = askopenfile(mode='r',
                       filetypes=[('All', '*'), ('Text files', '*.txt'),
                                  ('Hyper Text Language Markup', '*.html'),
                                  ('Comma-Separated Values', '*.csv')])
    if file is not None:
        text = file.read()
        blank.insert("1.0", text)


def save_file():
    notepad_text = blank.get("1.0", "end-1c")
    file = asksaveasfilename(title="Save",
                             filetypes=[('All', '*'), ('Text files', '*.txt'),
                                        ('Hyper Text Language Markup',
                                         '*.html'),
Exemplo n.º 3
0
import tkinter.scrolledtext as scrolledtext
from ttkthemes import ThemedTk

import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg,
                                               NavigationToolbar2Tk)

root = ThemedTk(theme='breeze')  # tema
root.title("Comerciante y manzanas")  # titulo
# tamaño de anchura de toda la ventana del ordenador
screen_width = root.winfo_screenwidth()
# tamaño de la altura toda la ventana del ordenador
screen_height = root.winfo_screenheight()
root.geometry(f"{screen_width}x{screen_height}")
root.minsize(1200, 700)

# root.iconbitmap('/logo.ico')


def cleanAll():
    main.wrapperGeneratorTests.pack_forget()
    main.wrapperSimulatorInv.pack_forget()
    main.wrapperHelp.pack_forget()


def openHelp():
    cleanAll()
    main.wrapperHelp.pack(expand="yes", fill="both")

from tkinter import ttk
conversion_can_do = ('png', 'gif', 'tiff', 'ico', 'jpg', 'bmp'
                     )  # Formats That This Converter Can Do.
conversion_can_do_with_pdf = ('png', 'gif', 'tiff', 'ico', 'jpg', 'bmp', 'pdf'
                              )  # Formats That This Converter Can Do.
from tkinter import filedialog
from PIL import Image
import os  # arc
root = ThemedTk(themebg=True)  # Our Main Window.
root.set_theme('arc')
opend_file_path = ttk.Label(
    root, text=None)  # Creating Label For Showing Path Of Opened File.
saved_file_path = ttk.Label(
    root, text=None)  # Creating Label For Showing Path Of Saved File.
root.maxsize(500, 200)  # Maxsize Of Our Window is height=400,width=200
root.minsize(500, 200)  # Minsize Of Our Window is height=400,width=200
Slect_FILE_FROM_DONW_BELOW_OPTIOn = ttk.Label(
    root,
    text=
    'Select A Fromat To Import From Down Below Than Select File Type To Save'
)  # This Is Our Heading That Tells How To Use This Converter.
Slect_FILE_FROM_DONW_BELOW_OPTIOn.pack(
)  # Showing Our Label In Our Main Window That Means I Am Packing The Label.


def tkinter_window_is_closed(
):  # A Function That Ask Are You Sure Quit? When User Closes The Window.
    from tkinter import messagebox  # Importing messagebox For Asking Question.
    question = messagebox.askquestion('?',
                                      'Are You Sure Quit?')  # This Is Question
    if question == 'yes':  # If question answer is yes the destroy window If No Then Do Nothing.
Exemplo n.º 5
0
x_start = (width / 2) - 216
y_start = (height / 2) - 216
splashscreen.geometry('%dx%d+%d+%d' % (432, 432, x_start, y_start))
canvas = Canvas(splashscreen, height=432, width=432, bg="yellow")
canvas.pack()
image = PhotoImage(file="BombermanSigil.gif")

canvas.create_image(216, 216, image=image)

splashscreen.after(2500, splashscreen.destroy)
splashscreen.mainloop()

main_win = ThemedTk(theme="black")
main_win.configure(background='#626262')
main_win.minsize(width=800, height=300)
main_win.title("Bolibompa3")

ttk.Style().configure("black.Treeview", borderwidth=15)

main_win.finale_file = ''
gff_file = ''
create_order = 0

pyrocues = []
dmxques = []
shortcutFile = open('shortcuts.csv', 'r')

plocka_eget = []
plocka_gff = []
errors = []
Exemplo n.º 6
0
        result_frame.grid_propagate(0)  # 组件大小不变

        # 目标反馈与评价
        feedback_frame = LabelFrame(self.cv_frame, text="第七步:目标反馈评价", width=600, height=50, bg='#fff2cc')
        feedback_frame.grid(row=6, column=0, sticky=W)
        feedback_frame.grid_propagate(0)  # 组件大小不变

    def return_main(self):
        """
        回到主页
        :return:
        """
        print("Event:回到主页")
        self.__init__(self.root)


if __name__ == "__main__":
    # 创建一个Top Level的根窗口, 并把他们作为参数实例化为App对象
    # root = tk.Tk()
    root = ThemedTk(theme="arc")
    root.title("CAICT地图绘制工具箱(CAICT-AtlasToolkit)")
    center_window(root, 0, 0)  # 设置窗口位置
    # root.maxsize(750, 800)
    root.minsize(770, 690)  # 设置窗口最小尺寸
    root.resizable(0, 0)  # 锁定尺寸
    # root.attributes("-alpha", 0.80)
    app = App(root)
    # 开始主事件循环
    root.mainloop()

Exemplo n.º 7
0
        check = (star_a.endswith('.mp4'))
        check_ = (star_a.endswith('.avi'))
        check_1 = (star_a.endswith('.ogv'))
        if check == True:
            convert_button.config(command=video_to_audio)
            convert_button.config(state=NORMAL)
            open_file_path.config(text=f'Opened File Path:-{path_opend_file_}')
        if check_ == True:
            convert_button.config(command=video_to_audio)
            convert_button.config(state=NORMAL)
            open_file_path.config(text=f'Opened File Path:-{path_opend_file_}')
        if check_1 == True:
            convert_button.config(command=video_to_audio)
            convert_button.config(state=NORMAL)
            open_file_path.config(text=f'Opened File Path:-{path_opend_file_}')
    except Exception:
        convert_button.config(state=DISABLED)


r.minsize(500, 200)
r.maxsize(500, 200)
r.title('Video To Audio')
r.geometry('500x200')
heading = ttk.Label(r, text='Video File to Audio File ', font=('Font', 10))
heading.place(x=100 + 25 + 5 + 5 + 5 + 15, y=1)
browse_mp4 = ttk.Button(r, text='Browse A Video File', command=dialog_video)
browse_mp4.place(x=172, y=55)
mainloop()
# -----------------------------------------------------
# ----------------------------------------
Exemplo n.º 8
0
HEIGHT = 650

# COLORS
# bg
canvasbg = '#212121'
framebg = '#3F51B5'
redbg = '#f44336'
greenbg = '#4CAF50'
# fg
whitefg = '#FFF'

runBTcolor = '#00C853'

root = ThemedTk(theme='equilux')
# root.resizable(False, False)
root.minsize(WIDTH, HEIGHT)
root.title('Wallhavener')
root.attributes("-alpha", 0.93)

# root.update_idletasks()
# root.overrideredirect(True)
# root.wait_visibility(root)
# root.attributes('-type', 'normal')
# root.attributes('-alpha', 0.8)

# Styling * ---- *


def gui_style():

    root.configure(background=canvasbg)
Exemplo n.º 9
0
def main():
    print("Scanner App Started...")

    # UI Updating Method
    def update_left_header_label(value):
        """UI Updating Method
        :param value: value to be set in left header
        """
        if value is None:
            # if the provided value is none, then update to the default header
            host_count = DataShare.get_hosts_total()
            host_count_text = f"({host_count}) Hosts Scanned".format()
            left_frame_header_label_var.set(host_count_text)
        else:
            # else
            left_frame_header_label_var.set(value)

    def update_left_header_label_random_waiting_msg():
        """Update waiting header randomly"""
        random_waiting_responses = [
            "This may take a while...", "I'm sorry this will be a while...",
            "Scanning...", "Scanning in Process..."
        ]
        update_left_header_label(random.choice(random_waiting_responses))

    def reset_left_header_label():
        """Update left header with number of hosts scanned"""
        host_count = DataShare.get_hosts_total()
        host_count_text = f"({host_count}) Hosts Scanned".format()
        left_frame_header_label_var.set(host_count_text)

    def reload_hosts_tableview():
        """Update hosts box with scanned hosts"""
        # hosts_listbox.delete(0, tk.END)
        sorted_scanned_hosts = None

        # Sort according to the Host Sort Setting
        reverse_sort = False

        if System.Settings.get_host_sort_type() == System.SortType.alphaDESC:
            reverse_sort = True

        if DataShare.get_hosts():
            sorted_scanned_hosts = sorted(DataShare.get_hosts(),
                                          key=lambda x: (x.get_display_name()),
                                          reverse=reverse_sort)

        if sorted_scanned_hosts is None:
            return

        # Update hosts to the sorted version to ensure details on select are correct
        DataShare.set_hosts(sorted_scanned_hosts)
        reset_left_header_label()

        data = list(
            map(
                lambda host:
                (host.get_ip(), host.get_display_name(), host.get_vendor()),
                sorted_scanned_hosts))

        # We need to reverse the data shown here because the table view will display the data in the reversed order
        # this is needed so that clicking the tableview will result in the correct host being selected: Task189
        hosts_table_view.reload_data(data[::-1])

    def scan_thread_completion():
        """Scan given inputs, update associated ui, and save scan data"""
        scan_start_date = datetime.datetime.now()
        update_left_header_label("Scan in process...")
        scan_button.config(state="disabled")
        waiting_scanner1 = STimer.do_after(
            update_left_header_label_random_waiting_msg, 15)
        waiting_scanner2 = STimer.do_after(
            update_left_header_label_random_waiting_msg, 30)
        waiting_scanner3 = STimer.do_after(
            update_left_header_label_random_waiting_msg, 45)

        ports = f'{port_start_entry_var.get()}-{port_end_entry_var.get()}'
        hosts = scan_host_entry_var.get()
        scanner = Scanner(hosts, ports)

        set_host(scanner.get_scan_details(System.Settings.get_scan_type()))
        set_cpes_vulns(scanner.get_cpes())

        scan_button.config(state="normal")
        scan_details_view.check_vulnerabilities_button.config(state="normal")

        scan_end_date = datetime.datetime.now()
        timedelta = scan_end_date - scan_start_date
        timedelta.total_seconds()

        last_row_id = df.DBFunctions.save_scan(scan_start_date,
                                               timedelta.total_seconds())

        for host in get_hosts():
            df.DBFunctions.save_host(host, last_row_id)

        query = "SELECT * FROM Hosts WHERE ScanID = ?"
        host_tuple = df.DBFunctions.get_all_where(query, (last_row_id, ))
        hosts_with_ID = []

        for id_host in host_tuple:
            temp = Host(id_host[0], id_host[1], "Old Host", id_host[5],
                        id_host[3], id_host[4], id_host[6], id_host[2])
            hosts_with_ID.append(temp)

        set_host(hosts_with_ID)

        ip_list = [*DataShare.get_cpes()]
        cpe_list = DataShare.get_cpes()

        for ip in ip_list:
            for item in hosts_with_ID:
                if item.get_ip() == ip:
                    cpe_list[item.get_id()] = cpe_list.pop(ip)

        DataShare.set_cpes(cpe_list)
        cves_with_host = df.DBFunctions.query_cves(cpe_list)

        for i in cves_with_host:
            for j in i:
                df.DBFunctions.save_cve_by_host(i, j)

        update_left_header_label(f"Scan finished in {timedelta} seconds")
        STimer.do_after(reset_left_header_label, 2)
        waiting_scanner1.cancel()
        waiting_scanner2.cancel()
        waiting_scanner3.cancel()

    def set_host(h):
        """Set scanned hosts for ui
        :param h: hosts found
        """
        if h:
            DataShare.set_hosts(h)
            reload_hosts_tableview()

    def get_hosts():
        """Get scanned hosts"""
        return DataShare.get_hosts()

    def set_cpes_vulns(c):
        """Set vulnerabilities from cps"""
        print("Main 172 set_cpes_vulns   cpes:\n")
        print(c)
        DataShare.set_cpes(c)

        # Sort according to the Vulnerability Sort Setting
        reverse_sort = False

        if System.Settings.get_vuln_sort_type() == System.SortType.alphaDESC:
            reverse_sort = True

        sorted_vulns = sorted(df.DBFunctions.query_cves(c),
                              reverse=reverse_sort)
        print('From Main 184, sorted_vulns: ', sorted_vulns)
        DataShare.set_vulns(sorted_vulns)
        # reload ui

    # Click Handlers
    def on_scan():
        """Click handler for scan btn to start scanner thread"""
        # MAKE SURE TO VALIDATE INPUT
        scan_thread = SThread(0, "SCAN_THREAD_1", 5, scan_thread_completion)
        scan_thread.start()

    def on_select_scan(id):
        query = "SELECT * FROM Hosts WHERE ScanID = ?"
        params = (id, )

        data = df.DBFunctions.get_all_where(query, params)
        test = df.DBFunctions.retrieve_scanID_data(id)
        print('\n\n\n\nGetting Data\n')
        print(data)
        print('\n')
        print(test)
        # these need to be set, but not sure if the cpes and vulns are differentiate
        # by scans like hosts are
        # todo: set cpes and vulns in DataShare
        print('\n\n\n\nCPES')
        #todo this changes depending on if a scan has been run
        print(DataShare.get_cpes())
        print('\n\nVULNS')
        #todo these are 2.2 cpes...
        print(DataShare.get_vulns())
        print('\n\n\n\n')

        curr_hosts = []
        # for each host scanned
        for host_raw in data:
            host_id = host_raw[0]

            ip = host_raw[1]
            state = "Old Host"
            mac = host_raw[2]
            os_gen = host_raw[3]
            os_family = host_raw[4]
            name = host_raw[5]
            vendor = host_raw[6]

            curr_hosts.append(
                Host(host_id, ip, state, name, os_family, os_gen, vendor, mac))

        set_host(curr_hosts)

    def find_exploit(cve):
        if cve:
            if exploit_view:
                exploit_view.update_cve(cve)
        else:
            print('No CVE selected')

    def update_exploit_tab(cve):
        main_note_book.select(2)
        exploit_view.cve_var.set(cve)
        exploit_view.on_search()

    def on_host_tableview_select(event):
        """Click handler to update right ui when user clicks on a host in left box"""
        index = hosts_table_view.get_selected_index()
        hosts = DataShare.get_hosts()

        scan_details_view.host_name_entry_var.set(
            hosts[index].get_display_name())
        scan_details_view.mac_address_entry_var.set(
            hosts[index].get_mac_address())
        scan_details_view.port_number_entry_var.set(hosts[index].get_ip())

    def donothing():
        filewin = Toplevel(root)
        button = Button(filewin, text="Do nothing button")
        button.pack()

    def update_import():
        # Only takes json currently. path = askopenfilename(title='Select Database file to import...',
        # defaultextension='.db', filetypes=(("database files", "*.db"),("datafeeds", "*.json"),("all files", "*.*")))

        path = askopenfilename(title='Select Database file to import...',
                               filetypes=[('Json', '*.json')])

        # ntpath for os compatibility with differing separators
        # head and tail if path ends in backslash
        head, tail = ntpath.split(path)
        fname = tail or ntpath.basename(head)

        if fname.endswith('.json'):
            # for use to support multiple file types
            # elif json_fp.endswith(('.json', '.db', '.xml'):
            df.DBFunctions.import_NVD_JSON(fname)
        else:
            tk.messagebox.showerror("Error", "File must be of type: json")

    # Set up tree columns to display IP and Device Names after a completed scan
    class TreeColumns(enum.Enum):
        name = 0
        mac_address = 1

        @staticmethod
        def display_name_for_column(col):
            display_names = {
                0: "IP",
                1: "Name",
            }
            return display_names[col]

        @staticmethod
        def all_cases():
            cases = []

            for col in TreeColumns:
                cases.append(TreeColumns.display_name_for_column(col.value))

            return cases

    # Setup root ui

    root = ThemedTk()
    root.ttkStyle = ThemedStyle()
    theme = System.Settings.get_theme()
    root.ttkStyle.set_theme(theme)
    root.title("AnyScan")
    root.grid_rowconfigure(0, weight=1)
    root.grid_columnconfigure(1, weight=1)

    #################
    # Setup LeftFrame
    #################
    left_frame = ttk.Frame(root)
    left_frame.grid(row=0, column=0, sticky="nsew")
    left_frame.grid_rowconfigure(1, weight=1)
    left_frame.grid_columnconfigure(1, weight=1)

    # Setup Left Frame header Label
    left_frame_header_label_var = tk.StringVar()
    update_left_header_label(None)
    left_frame_header_label = ttk.Label(
        left_frame, textvariable=left_frame_header_label_var)
    left_frame_header_label.grid(row=0, column=0)

    # Setup Left Frame Host TableView
    sections_tuple = TreeColumns.all_cases()
    data = []
    hosts_table_view = TableView(left_frame, 1, sections_tuple, data)
    hosts_table_view.bind_method('<ButtonRelease-1>', on_host_tableview_select)
    reload_hosts_tableview()

    # Setup scan host frame
    scan_host_frame = ttk.Frame(left_frame)
    scan_host_frame.grid(row=2, column=0)

    # Setup scan host label
    scan_host_label = ttk.Label(scan_host_frame, text="Hosts:")
    scan_host_label.grid(row=0, column=0)

    # Setup scan host entry
    scan_host_entry_var = tk.StringVar()
    scan_host_entry_var.set("192.168.1.0/28")
    scan_host_entry = ttk.Entry(scan_host_frame,
                                textvariable=scan_host_entry_var)
    scan_host_entry.grid(row=0, column=1)

    # Setup scan port label frame
    scan_port_label_frame = ttk.Frame(left_frame)
    scan_port_label_frame.grid(row=3, column=0)

    # Setup scan port label
    port_start_label = ttk.Label(scan_port_label_frame, text="Start Port")
    port_start_label.grid(row=0, column=0, padx=(0, 8))
    port_end_label = ttk.Label(scan_port_label_frame, text="End Port")
    port_end_label.grid(row=0, column=1, padx=(8, 0))

    # Setup scan port frame
    scan_port_frame = ttk.Frame(left_frame)
    scan_port_frame.grid(row=4, column=0)

    # Setup scan port entries
    port_start_entry_var = tk.StringVar()
    port_start_entry_var.set("21")
    port_start_entry = ttk.Entry(scan_port_frame,
                                 width=4,
                                 textvariable=port_start_entry_var)
    port_start_entry.grid(row=0, column=0, padx=(0, 16))

    port_end_entry_var = tk.StringVar()
    port_end_entry_var.set("30")
    port_end_entry = ttk.Entry(scan_port_frame,
                               width=4,
                               textvariable=port_end_entry_var)
    port_end_entry.grid(row=0, column=1, padx=(16, 0))

    scan_button_frame = ttk.Frame(left_frame)
    scan_button_frame.grid(row=5, column=0)

    # Setup Left frame scan button
    scan_button = ttk.Button(scan_button_frame, text="Scan", command=on_scan)

    scan_button.grid(row=0, column=0, pady=(8, 8))

    #################
    # Setup RightFrame
    #################

    # Setup Notebook for right frame
    rows = 0
    while rows < 50:
        root.columnconfigure(rows + 1, weight=1)
        rows += 1

    # Setup Root Notebook
    main_note_book = ttk.Notebook(root)

    main_note_book.grid(row=0,
                        column=1,
                        columnspan=50,
                        rowspan=49,
                        sticky="NESW")

    # Setup Scan Details Tab
    scan_details_view = ScanDetailsView()
    scan_details_tab = scan_details_view.get_view(main_note_book)
    main_note_book.add(scan_details_tab, text="Scan Details")

    # Setup Vulnerabilities Tab
    vulnerabilities_view = VulnerabilitiesView()
    vulnerabilities_tab = vulnerabilities_view.get_view(main_note_book)
    main_note_book.add(vulnerabilities_tab, text="Vulnerabilities")
    vulnerabilities_view.on_selected_cve = find_exploit
    vulnerabilities_view.move_to_exploit = update_exploit_tab

    # Setup Exploits Tab
    exploit_view = ExploitView()
    exploit_tab = exploit_view.get_view(main_note_book)
    main_note_book.add(exploit_tab, text='Exploits')

    # Setup Scan History Tab
    scan_history_view = ScanHistoryView()
    scan_history_tab = scan_history_view.get_view(main_note_book)
    main_note_book.add(scan_history_tab, text="Scan History")
    scan_history_view.on_selected_scan_completion = on_select_scan

    # File Menu Bar
    menubar = Menu(root)  # create menu bar
    filemenu = Menu(menubar, tearoff=0)  # create a menu to add some stuff too

    # Save Vulnerability in file menu bar
    savemenu = Menu(menubar, tearoff=0)
    savemenu.add_command(label="Save Vulnerability",
                         command=VulnPopup.new_popup)
    filemenu.add_cascade(label='Save', menu=savemenu)

    # DB import in file menu bar
    importmenu = Menu(menubar, tearoff=0)
    importmenu.add_command(label="Database", command=update_import)
    filemenu.add_cascade(label="Import", menu=importmenu)
    filemenu.add_separator()  # more prettiness

    # Scan settings in file menu bar
    settingsmenu = Menu(menubar, tearoff=0)
    settingsmenu.add_command(label="Scan Settings",
                             command=scan_details_view.on_settings)
    filemenu.add_cascade(label='Settings', menu=settingsmenu)
    filemenu.add_separator()  # pretty

    # Helper method to change application themes
    def change_theme(theme):
        root.ttkStyle.set_theme(theme)
        System.Settings.set_theme(theme)

    # Added the ability for the user to change themes from the cascading file menu
    themes_menu = Menu(menubar, tearoff=0)
    themes_menu.add_command(label="Alt", command=lambda: change_theme("alt"))
    themes_menu.add_command(label="Aqua", command=lambda: change_theme("aqua"))
    themes_menu.add_command(label="Clam", command=lambda: change_theme("clam"))
    themes_menu.add_command(label="Classic",
                            command=lambda: change_theme("classic"))
    themes_menu.add_command(label="Default",
                            command=lambda: change_theme("default"))
    themes_menu.add_command(label="Equilux",
                            command=lambda: change_theme("equilux"))
    themes_menu.add_separator()
    themes_menu.add_command(label="Scidblue",
                            command=lambda: change_theme("scidblue"))
    themes_menu.add_command(label="Scidgreen",
                            command=lambda: change_theme("scidgreen"))
    themes_menu.add_command(label="Scidgrey",
                            command=lambda: change_theme("scidgrey"))
    themes_menu.add_command(label="Scidmint",
                            command=lambda: change_theme("scidmint"))
    themes_menu.add_command(label="Scidpink",
                            command=lambda: change_theme("scidpink"))
    themes_menu.add_command(label="Scidpurple",
                            command=lambda: change_theme("scidpurple"))
    themes_menu.add_command(label="Scidsand",
                            command=lambda: change_theme("scidsand"))

    filemenu.add_cascade(label='Change Theme', menu=themes_menu)
    filemenu.add_separator()
    filemenu.add_command(label="Exit", command=root.quit)

    editmenu = Menu(menubar,
                    tearoff=0)  # create another menu to add some stuff too
    editmenu.add_command(label="Undo", command=donothing)

    menubar.add_cascade(label="File", menu=filemenu)  # add file to menu bar
    # On macOS there are some default things added to this menu, but are not added to the same menu
    # under File.
    menubar.add_cascade(label='Edit',
                        menu=editmenu)  # add edit to menu bar too, for fun

    # Run the program with UI
    root.config(menu=menubar)
    root.geometry("1600x1000")
    root.minsize(800, 500)
    # add this to ensure app comes to front on start up
    root.lift()
    root.attributes('-topmost', True)
    root.after_idle(root.attributes, '-topmost', False)
    # start GUI
    root.mainloop()
Exemplo n.º 10
0
def make_root_window(width=500, height=700):
    root = ThemedTk(theme="arc")
    root.title("Password Manager")
    root.geometry(f'{width}x{height}')
    root.minsize(480, 300)
    return root
Exemplo n.º 11
0

def next_image():
    global img_no
    try:
        if len(paths) != 0 and img_no < len(paths) - 1:
            img_no += 1
            set_image()
    except:
        pass


root = ThemedTk(theme='arc')
root.title('Photos')
root.geometry('800x600+230+30')
root.minsize(800, 600)
root.iconbitmap('./res/icon.ico')
root.config(bg='white')

# Variables
img_no = 0
paths = []

# Frames
photo_frame = LabelFrame(root, borderwidth=10, bg='white')
photo_frame.pack(expand=True, fill='both')

btn_frame = Frame(root, bg='white')
btn_frame.pack(side=BOTTOM, pady=10)

# Label for image
Exemplo n.º 12
0
class Toplevel1:
    def __init__(self):
        '''This class configures and populates the toplevel window.
		   top is the toplevel containing window.'''
        self.style = ttk.Style()
        self.root = ThemedTk(theme="arc")
        # self.root = tk.Tk()
        self.root.geometry("1200x661+284+114")
        self.root.minsize(120, 1)
        self.root.maxsize(1924, 1061)
        self.root.resizable(1, 1)
        self.root.title("New Toplevel")
        # top.configure(background="#d9d9d9")
        #
        # self.menubar = tk.Menu(top,font="TkMenuFont",bg=_bgcolor,fg=_fgcolor)
        # top.configure(menu = self.menubar)

        # self.style.configure('TNotebook.Tab', background=_bgcolor)
        # self.style.configure('TNotebook.Tab', foreground=_fgcolor)
        # self.style.map('TNotebook.Tab', background=
        #     [('selected', _compcolor), ('active',_ana2color)])
        self.TNotebook1 = ttk.Notebook(self.root)
        self.TNotebook1.place(relx=0.0, rely=0.0, relheight=1.0, relwidth=1.0)
        self.TNotebook1.configure(takefocus="")
        self.TNotebook1_t1 = tk.Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t1, padding=3)
        self.TNotebook1.tab(
            0,
            text="Page 1",
            compound="left",
            underline="-1",
        )
        self.TNotebook1_t2 = tk.Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t2, padding=3)
        self.TNotebook1.tab(
            1,
            text="Page 2",
            compound="left",
            underline="-1",
        )
        self.f = tk.Frame(self.TNotebook1_t1, width=20, height=100)
        self.f.place(x=0, y=0)
        self.set_button()

        # self.f2 = tk.Frame(self.TNotebook1_t1, width=20, height=100, bg="blue")
        # self.f2.place(x=0, y=600,anchor="nw")
        # self.set_label()

    def set_button(self):
        button = tk.Button(self.TNotebook1_t1,
                           text="bt",
                           command=self.add_label_thread)
        button.pack()

    def add_label(self):
        while True:

            lb = tk.Button(self.f, text=1)
            lb.pack()
            time.sleep(2)

    def add_label_thread(self):
        p = Thread(target=self.add_label)
        p.start()
from tkinter import ttk  # Normal Tkinter.* widgets are not themed!
from ttkthemes import ThemedTk
from tkinter import messagebox
import pygame
from tkinter.filedialog import askopenfilename
import os
from mutagen.mp3 import MP3

pygame.init()

root = ThemedTk(theme="radiance")
root.title("Melody")
root.iconbitmap('images/melody_icon.ico')
root.geometry('620x300')
root.maxsize(620, 300)
root.minsize(620, 300)
text = tk.Label(root, text="Melody Music Player", font='Helvetica 18 bold')
text.pack()

status = tk.Label(root, text="Status bar", font='Helvetica 9',
                  relief='sunken', anchor="w")
status.pack(side="bottom", fill='x')

mp3_len_show = ttk.Label(root, text="", font='Helvetica 11')
mp3_len_show.pack()


def about_us():
    tk.messagebox.showinfo("Message", "This is About Us!")

class Program:
    """Exampleprogram to show possible usage of the module csvxmlImporter"""
    __importer: CsvXmlImporter
    __settings: dict

    def __init__(self):
        """__init__ creates the tkinter gui"""
        self.__settings = {}
        self.__importer = CsvXmlImporter()

        # ***--*** main window and menu band ***---***
        self.__root = ThemedTk(theme=theme)
        self.__root.title("Csv/Xml Importer")
        self.__root.minsize(560, 1)
        menu = Menu(self.__root)
        self.__root.config(menu=menu)

        filemenu = Menu(menu, tearoff=0)
        menu.add_cascade(label="File", menu=filemenu)
        filemenu.add_command(label="Add Files", command=self.add_files)
        filemenu.add_command(label="Remove All", command=self.remove_all)
        filemenu.add_separator()
        filemenu.add_command(label="Add xsl File", command=self.add_xslfile)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.exit)

        helpmenu = Menu(menu, tearoff=0)
        menu.add_cascade(label="Help", menu=helpmenu)
        helpmenu.add_command(label="?", command=self.ask_help)
        helpmenu.add_command(label="About", command=self.ask_about)

        # ***---*** source file frame dialog ***---***
        srcfilesframe = LabelFrame(self.__root, text="Sourcefiles")
        buttonframe = Frame(srcfilesframe)
        addbutton = Button(buttonframe,
                           text="Add Files",
                           command=self.add_files)
        addbutton.pack(fill=X)
        removefilesbutton = Button(buttonframe,
                                   text="Remove Selected",
                                   command=self.remove_files)
        removefilesbutton.pack(fill=X)
        removeallbutton = Button(buttonframe,
                                 text="Remove All",
                                 command=self.remove_all)
        removeallbutton.pack(fill=X)
        buttonframe.grid(column=1, row=1)
        self.__srcfileslistbox = Listbox(srcfilesframe,
                                         selectmode="extended",
                                         width=100,
                                         height=5)
        self.__srcfileslistbox.grid(column=2, row=1)

        Label(srcfilesframe, text="Encoding").grid(column=1, row=2, sticky=E)
        self.__settings["encoding"] = StringVar()
        self.__settings["encoding"].trace_add("write", self.update_settings)
        encCombobox = Combobox(srcfilesframe,
                               textvariable=self.__settings["encoding"],
                               values=encodings,
                               state="readonly")
        encCombobox.bind("<FocusOut>", self.update_settings)
        encCombobox.grid(column=2, row=2, pady=10)
        srcfilesframe.pack(fill=X)

        # ***---*** xsl file dialog ***---***
        xslfileframe = LabelFrame(self.__root, text="XSL-File")
        Button(xslfileframe, text="Add .xsl",
               command=self.add_xslfile).grid(column=1, row=1)
        self.__xsllistbox = Listbox(xslfileframe, width=100, height=1)
        self.__xsllistbox.grid(column=2, row=1, sticky="w")
        buttonframe = Frame(xslfileframe)
        Button(buttonframe,
               text="Apply Parameter",
               command=self.apply_xslparameter).pack(fill=X)
        Button(buttonframe,
               text="Restore Default",
               command=self.reset_xslparameter).pack(fill=X)
        buttonframe.grid(column=1, row=2)
        box = Frame(xslfileframe)
        self.__xslparametertext = Text(box, height=3, width=75)
        self.__xslparametertext.grid(column=0, row=1, sticky="nsew")
        scrollbar = Scrollbar(box, command=self.__xslparametertext.yview)
        scrollbar.grid(column=0, row=1, sticky="nse")
        box.grid(column=2, row=2, sticky="we")
        self.__xslparametertext["yscrollcommand"] = scrollbar.set
        xslfileframe.pack(fill=X)

        # ***---*** file format settings dialog ***---***
        # small help function
        def limit_character(entry_text):
            """limit_characters cuts down the characters of an entry text to one"""
            if len(entry_text.get()) > 0:
                # take only last input character and throw away the rest
                entry_text.set(entry_text.get()[-1])

        fileformatsettingsframe = LabelFrame(self.__root,
                                             text="File Format Settings")

        Label(fileformatsettingsframe, text="Delimiter").grid(column=1,
                                                              row=1,
                                                              sticky=E)
        self.__settings["delimiter"] = StringVar()
        seperatorentry = Entry(fileformatsettingsframe,
                               textvariable=self.__settings["delimiter"],
                               width=1)
        self.__settings["delimiter"].trace_add(
            "write", lambda *_: limit_character(self.__settings["delimiter"]))
        seperatorentry.bind("<Return>", self.update_settings)
        seperatorentry.bind("<FocusOut>", self.update_settings)
        seperatorentry.grid(column=2, row=1, sticky=W, padx=15)

        Label(fileformatsettingsframe, text="Quotechar").grid(column=1,
                                                              row=2,
                                                              sticky=E)
        self.__settings["quotechar"] = StringVar()
        quotecharentry = Entry(fileformatsettingsframe,
                               textvariable=self.__settings["quotechar"],
                               width=1)
        self.__settings["quotechar"].trace_add(
            "write", lambda *_: limit_character(self.__settings["quotechar"]))
        quotecharentry.bind("<Return>", self.update_settings)
        quotecharentry.bind("<FocusOut>", self.update_settings)
        quotecharentry.grid(column=2, row=2, sticky=W, padx=15)

        Label(fileformatsettingsframe, text="Doublequote").grid(column=1,
                                                                row=3,
                                                                sticky=E)
        self.__settings["doublequote"] = BooleanVar()
        Checkbutton(fileformatsettingsframe,
                    variable=self.__settings["doublequote"],
                    command=self.update_settings).grid(column=2,
                                                       row=3,
                                                       sticky=W,
                                                       padx=10)

        Label(fileformatsettingsframe, text="Quoting").grid(column=1,
                                                            row=5,
                                                            sticky=E)
        quotingopt = {"minimal": 0, "all": 1, "non numeric": 2, "none": 3}
        self.__settings["quoting"] = IntVar()
        for i, (key, value) in enumerate(quotingopt.items()):
            Radiobutton(
                fileformatsettingsframe,
                text=key,
                value=value,
                variable=self.__settings["quoting"],
                command=self.update_settings,
            ).grid(
                column=2 + i,
                row=5,
                padx=10,
                sticky=W,
            )

        Label(fileformatsettingsframe,
              text="Ignore spaces at beginning").grid(column=1,
                                                      row=6,
                                                      sticky=E)
        self.__settings["skipinitialspace"] = BooleanVar()
        self.__settings["skipinitialspace"].set(False)
        Checkbutton(fileformatsettingsframe,
                    variable=self.__settings["skipinitialspace"],
                    command=self.update_settings).grid(column=2,
                                                       row=6,
                                                       sticky=W,
                                                       padx=10)

        fileformatsettingsframe.pack(fill=X)

        # ***---*** preview frame ***---***
        previewframe = LabelFrame(self.__root, text="Preview")
        self.__pdtable = Table(parent=previewframe,
                               dataframe=self.__importer.dfx)
        self.__pdtable.show()
        previewframe.pack(fill="both", expand=True)

        # ***---*** export button ***---***
        exportframe = LabelFrame(self.__root, text="Export")
        Button(exportframe, text="Export",
               command=self.create_exportdialog).pack()
        exportframe.pack(fill="both", expand=True)

        # save settings to check for changes on update
        self.__prevsettings = self.__unpack_settings(self.__settings)

    def run(self):
        """run starts the mainloop of tkinter gui"""
        self.__root.mainloop()

    def exit(self):
        """exit closes tkinter application"""
        self.__root.destroy()

    def add_files(self):
        """add_files called by user to add files via dialog"""
        names = askopenfilenames(title="Select .csv or .xml files",
                                 filetypes=(("any", "*.*"),
                                            ("Csv File", "*.csv"), ("Xml File",
                                                                    "*.xml")))
        if names:
            try:
                self.__srcfileslistbox.insert(END, *names)
                self.__importer.update_files(
                    *self.__srcfileslistbox.get(0, END))
            except AttributeError as e:
                showerror(title="Error", message="No .xsl file set")
            except ValueError as _:
                showerror(title="Error", message="Could not open files")
                self.__srcfileslistbox.delete(0, END)

            self.__update_table()
            self.__update_dialog()

    def remove_files(self):
        """remove_files called by user to remove in listbox selected files"""
        itemstodelete = self.__srcfileslistbox.curselection()
        if itemstodelete:
            for i in itemstodelete:
                self.__srcfileslistbox.delete(i)

            x = self.__srcfileslistbox.get(0, END)
            if x:
                self.__importer.update_files(*x)
            else:
                self.__importer.reset()
            self.__update_table()

    def remove_all(self):
        """remove_all called by user to remove all imported files"""
        self.__srcfileslistbox.delete(0, END)
        self.__importer.reset()
        self.__update_table()

    def add_xslfile(self):
        """add_xslfile called to open .xsl file via dialog"""
        filename = askopenfilename(title="Select .xsl file",
                                   filetypes=(("Xsl File", "*.xsl"), ))
        if filename:
            self.__importer.set_xslfile(filename)
            self.__xsllistbox.insert(0, filename)
            self.reset_xslparameter()

    def apply_xslparameter(self):
        """apply_xslparameter reads userinput from textbox and parses input in dict"""
        param = self.__xslparametertext.get("1.0", END)
        with StringIO(param) as f:
            lines = [line[:-1] for line in f.readlines()]
            # escape_decode removes extra escapes added through reading the text
            d = {
                x.split("=")[0]: escape_decode(x.split("=")[1])[0]
                for x in lines if x
            }
            self.__importer.set_xslparameter(**d)
        if not self.__importer.dfx.empty:
            self.__importer.update_files()
            self.__update_table()

    def reset_xslparameter(self):
        """reset_xslparameter restores default values for xslparameters"""
        self.__xslparametertext.delete("1.0", END)
        param = self.__importer.get_xslparameter(default=True)
        s = ""
        for key, item in param.items():
            s += repr(key + "=" + item)[1:-1] + '\n'
        self.__xslparametertext.insert("1.0", s)

    @staticmethod
    def __unpack_settings(settings):
        """__unpack_settings takes settings in form of dict with tkinter variables and unpacks them"""
        return dict((key, settings[key].get()) for key in settings)

    def __update_table(self):
        """__update_table updates pandastable to display the actual dataframe"""
        self.__pdtable.updateModel(TableModel(self.__importer.dfx))
        self.__pdtable.redraw()

    def __update_dialog(self):
        """__update_dialog updates the input fields with settings from the importer"""
        importersettings = self.__importer.get_settings()
        for key in self.__settings:
            if key in importersettings:
                self.__settings[key].set(importersettings[key])

    def update_settings(self, *_):
        """update_settings reads input fields and applies the user input to the importer"""
        newsettings = self.__unpack_settings(self.__settings)
        if newsettings != self.__prevsettings:
            # figure out which settings changed
            changedsettings = dict(newsettings.items() -
                                   self.__prevsettings.items())

            self.__importer.set_settings(**changedsettings)
            self.__prevsettings = newsettings
            if not self.__importer.dfx.empty:
                self.__update_table()

    def ask_help(self):
        showinfo(title="Help",
                 message="""\
    To import files select Add Files
    For .xml import first add a .xsl file.
    To export select Export and set desired parameters\
    """)

    def ask_about(self):
        showinfo(
            title="About",
            message="Projektarbeit Python\nAuthor: Leo Schurrer\nDate: 19/12/20"
        )

    def create_exportdialog(self):
        ExportDialog(self.__importer.dfx).run()
Exemplo n.º 15
0
from tkinter import *
from tkinter import ttk, filedialog, messagebox
from ttkthemes import ThemedTk
import base64
import ballot_page
import random
import os
import client
from PIL import Image,ImageTk
import doc_gen

sc = ThemedTk(theme="arc")
sc.title("Login")
sc.iconbitmap("gov2.ico")
sc.minsize(600, 400)
sc.resizable(False,False)
te1 = StringVar()
te2 = StringVar()
te3 = StringVar()
te4 = StringVar()
te5 = StringVar()
te6 = StringVar()
te10 = StringVar()
tctzn = StringVar()
tcon = StringVar()
tgen = StringVar()
phdir = StringVar()
date = StringVar()
te11 = StringVar()
te12 = StringVar()
selfil = StringVar()
Exemplo n.º 16
0
from tkinter import *
import tkinter as tk
from tkinter import ttk
from ttkthemes import ThemedTk
import threading
import temp_ser
from tkinter import messagebox
import _tkinter
import time
import sqlite3
import base64
sc=ThemedTk(theme="arc")
sc.minsize(300,300)
sc.resizable(False,False)
sc.title("server_status")
sc.iconbitmap("gov2.ico")
l=Label(sc,font={"10"},fg="green")
i=0
global tctzn
tctzn=StringVar
def staser():
    def th():
        i=0
        t1=threading.Thread(target=temp_ser.main)
        t1.daemon=True
        t1.start()

        b2.destroy()
        b1 = ttk.Button(sc, text="Stop Server", command=ext)
        b1.place(relx=0.38, rely=0.3)
Exemplo n.º 17
0
class Toplevel1:
    def __init__(self):
        '''This class configures and populates the toplevel window.
		   top is the toplevel containing window.'''
        # _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        # _fgcolor = '#000000'  # X11 color: 'black'
        # _compcolor = '#d9d9d9' # X11 color: 'gray85'
        # _ana1color = '#d9d9d9' # X11 color: 'gray85'
        # _ana2color = '#ececec' # Closest X11 color: 'gray92'
        self.style = ttk.Style()
        # if sys.platform == "win32":
        #     self.style.theme_use('winnative')
        # self.style.configure('.',background=_bgcolor)
        # self.style.configure('.',foreground=_fgcolor)
        # self.style.configure('.',font="TkDefaultFont")
        # self.style.map('.',background=
        #     [('selected', _compcolor), ('active',_ana2color)])
        self.root = ThemedTk(theme="arc")
        # self.root = tk.Tk()

        self.root.geometry("1200x661+284+114")
        self.root.minsize(120, 1)
        self.root.maxsize(1924, 1061)
        self.root.resizable(1, 1)
        self.root.title("New Toplevel")
        # top.configure(background="#d9d9d9")
        #
        # self.menubar = tk.Menu(top,font="TkMenuFont",bg=_bgcolor,fg=_fgcolor)
        # top.configure(menu = self.menubar)

        # self.style.configure('TNotebook.Tab', background=_bgcolor)
        # self.style.configure('TNotebook.Tab', foreground=_fgcolor)
        # self.style.map('TNotebook.Tab', background=
        #     [('selected', _compcolor), ('active',_ana2color)])
        self.TNotebook1 = ttk.Notebook(self.root)
        self.TNotebook1.place(relx=0.0, rely=0.0, relheight=1.0, relwidth=1.0)
        self.TNotebook1.configure(takefocus="")
        self.TNotebook1_t1 = tk.Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t1, padding=3)
        self.TNotebook1.tab(
            0,
            text="Page 1",
            compound="left",
            underline="-1",
        )
        self.TNotebook1_t2 = tk.Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t2, padding=3)
        self.TNotebook1.tab(
            1,
            text="Page 2",
            compound="left",
            underline="-1",
        )
        self.f = tk.Frame(self.TNotebook1_t1, width=20, height=100, bg="red")
        self.f.place(x=0, y=0)

        # self.f2 = tk.Frame(self.TNotebook1_t1, width=20, height=100, bg="blue")
        # self.f2.place(x=0, y=600,anchor="nw")
        # self.set_label()

    def inner(self):
        # while 1:
        time.sleep(3)
        lb = ttk.Label(self.f, text=1)
        lb.pack()

    def wapr(self):
        self.inner()

    def set_label(self):
        p = Process(target=self.wapr())
        p.start()

    #
    # def set_label(self): # 使用这个会报错 pickle 不能序列化lambda
    # 	p = Process(target=self.inner) # Call unbound method with explicit self
    # 	p.start()                      # Can't pickle 'tkapp' object

    def set_button(self):
        button = tk.Button(self.TNotebook1_t1,
                           text="bt",
                           command=self.set_label)
        button.pack()
Exemplo n.º 18
0
    # Personnalisation Style
    style = Style(window)
    original_font = font.nametofont(style.lookup("TLabel", "font"))
    f = font.Font(**original_font.configure())
    f.configure(weight='bold', underline=0, size=9)
    style.configure('H1.TLabel', font=f)
    original_font = font.nametofont(style.lookup("TButton", "font"))

    f2 = font.Font(**original_font.configure())
    f2.configure(weight='bold', size=9)
    style.configure('H1.TButton', font=f2)

    window.grid_columnconfigure(0, weight=1)
    window.grid_rowconfigure(0, weight=1)
    window.minsize(MIN_WIDTH, MIN_HEIGHT)

    # FRAME Principale
    frame_principale = Frame(window)
    frame_principale.grid_columnconfigure(0, weight=1)
    frame_principale.grid_rowconfigure(0, weight=1)
    frame_principale.grid(sticky='NSEW')

    label_fonct = Label(frame_principale, text='Fonctionnel', style='H1.TLabel')
    bouton_lancer = Button(frame_principale, text="Incrémenter dates XML", command=ouvrir_incrementeur_date)
    bouton_dl_visualiseur = Button(frame_principale, text="installation visualiseur d'offres", command=installer_visualiseur)
    label_java = Label(frame_principale, text='Code Java', style='H1.TLabel')
    bouton_lancer_traque = Button(frame_principale, text="Vérifier clés messages", command=ouvrir_traque_mes_cles)
    label_version = Label(frame_principale, text="v" + __version__, font=('Arial', 8), anchor='se')

    label_fonct.grid(row=0, column=0, pady=(15, 5))
        img_lable_python.pack(anchor=W)

    def show(self):
        print("User:<< %s >>" % self.e1.get())
        print("Password:<< %s >>" % self.e2.get())
        self.e1.delete(0, END)
        # self.e1.insert(0, "请输入用户名…")
        self.e2.delete(0, END)
        print("区域控制条S1:%s" % self.s1.get())
        # print("可滚动的框lb:%s" % self.lb.get(self.lb.curselection()))

    def test_entry(self):
        if len(self.e1.get()) > 6:
            print("输入正确!")
            return True
        else:
            # print("输入长度不够,请重新输入!")
            tk.messagebox.showinfo("提示", "输入用户名长度不够,请重新输入!")
            self.e1.delete(0, END)
            return False


if __name__ == "__main__":
    # 创建一个top level的根窗口,并把他作为参数实例化APP对象
    # root = tk.Tk()
    root = ThemedTk(theme="arc")
    root.minsize(400, 870)  # 设置最小尺寸
    app = App(root)
    # 开始主事件循环
    root.mainloop()