コード例 #1
0
def apt_install():
    global apt_install
    top = Toplevel()
    top.title('APT-GET Installation')
    top.geometry('250x130')
    start = Label(top, text="Starting application install").grid(row=0,
                                                                 columnspan=2,
                                                                 pady=10,
                                                                 padx=10)
    args = ['sudo', 'apt-get', 'update']
    args2 = ['sudo', 'apt-get', 'upgrade -y']
    #subprocess start
    updating = subprocess.Popen(args, stdout=subprocess.PIPE, shell=False)
    upgrading = subprocess.Popen(args2,
                                 stdin=updating.stdout,
                                 stdout=subprocess.PIPE,
                                 shell=False)
    updating.stdout.close()
    #exit button
    top.close_button = Button(top,
                              text="Back",
                              command=top.destroy,
                              bg='grey',
                              font='black')
    top.close_button.grid(pady=5, padx=10)

    if updating and updating:
        wai = Label(top, text="system updated")
        wai.grid(row=2, columnspan=1, padx=10, pady=10)
    elif start:
        wai2 = Label(top, text="system upgraded")
        wai2.grid(row=2, columnspan=1, padx=10, pady=10)
コード例 #2
0
from tkinter import Tk, Label, Button, StringVar, Toplevel, mainloop
from tkinter import E, N, S, W
import os, subprocess, time

top = Toplevel()
top.title('YUM Installation')
top.geometry('200x140')
init = Label(top, text="Starting application install").grid(row=0,
                                                            columnspan=2,
                                                            pady=10,
                                                            padx=10)
#time.sleep(2)
first_label = subprocess.Popen(['sudo', 'yum', 'update'],
                               shell=False,
                               input="")
#output = Button(top, text='run', command=first_label)
top.close_button = Button(top,
                          text="Back",
                          command=top.destroy,
                          bg='grey',
                          font='black')
top.close_button.grid(pady=5, padx=10)

if first_label:
    WAI = Label(top, text="Application installed sucessfully")
    WAI.grid(row=5, columnspan=1, padx=10, pady=10)
#def script():
#    top =Toplevel()

top = Toplevel
mainloop()
コード例 #3
0
ファイル: timer2.py プロジェクト: fo3cus/countdown_timer
def settings():
    global working

    working = 0

    win = Toplevel()
    win.title("Settings")
    win.config(bg="black", bd="1", relief="flat")
    win.resizable(height=False, width=False)
    my_font1 = font.Font(family="Helvetica", size=12, weight="normal")
    my_font2 = font.Font(family="Helvetica", size=18, weight="bold")

    cfg = configparser.ConfigParser()
    cfg.read(SETTINGS_FILE)

    # Variables
    minute_value = StringVar(win)
    minute_value.set(cfg['SETTINGS']['minutes'])
    second_value = StringVar(win)
    second_value.set(cfg['SETTINGS']['seconds'])

    def save():
        global iMin
        global iSec
        global iTotal

        if spin_minutes.get() == '':
            iMin = 0
        else:
            iMin = int(spin_minutes.get())

        if spin_seconds.get() == '':
            iSec = 0
        else:
            iSec = int(spin_seconds.get())

        config_file = open(SETTINGS_FILE, 'w')
        cfg.set('SETTINGS', 'minutes', str(iMin))
        cfg.set('SETTINGS', 'seconds', str(iSec))
        cfg.write(config_file)
        config_file.close()

        iTotal = str(f'{iMin:02}') + ":" + str(f'{iSec:02}')

        win.destroy()

        reset()

    def close():
        win.destroy()  # Close the GUI

    # Validate input and disallow anything but numbers and empty
    def validate_numbers(P, s):
        # print(P)  # Used for debugging
        if P.isdigit():  # Does the string evaluate to a number?
            if int(P) > 59:  # Is the number greater than 59
                win.bell()
                return False  # Disallow
            return True  # Allow
        elif P == '':
            return True
        else:
            win.bell()  # Error sound
            return False

    # Widgets
    spinput = win.register(validate_numbers)
    spin_minutes = Spinbox(
        win,  # Window element is assigned to
        validate="key",  # Validate on key press
        validatecommand=(spinput, "%P",
                         "%s"),  # Execute this command to validate
        from_=0,  # Minimum value when using arrows
        to=59,  # Maximum value when using arrows
        textvariable=minute_value,  # Set initial value
        bg="black",  # Background colour
        relief="flat",  # Border design
        fg="white",  # Text colour
        bd=1,  # Border width in pixels
        width=3,  # Width of spinbox entry in characters
        font=my_font2,  # Font for text
        justify="center"  # Alignment of text in element
    )
    spin_minutes.grid(row=0, column=0, padx=10, pady=10)  # Layout in window

    spin_seconds = Spinbox(win,
                           validate="key",
                           validatecommand=(spinput, "%P", "%s"),
                           from_=0,
                           to=59,
                           textvariable=second_value,
                           bg="black",
                           relief="flat",
                           fg="white",
                           bd=1,
                           width=3,
                           font=my_font2,
                           justify="center")
    spin_seconds.grid(row=0, column=1, padx=10, pady=10)

    win.save_button = Button(win,
                             text="Save",
                             command=save,
                             font=my_font1,
                             bg="black",
                             relief="flat",
                             fg="white",
                             bd=1,
                             width=5,
                             justify="center",
                             padx=5,
                             pady=5)
    win.save_button.grid(row=1, column=0, padx=10, pady=10)

    win.close_button = Button(win,
                              text="Close",
                              command=close,
                              font=my_font1,
                              bg="black",
                              relief="flat",
                              fg="white",
                              bd=1,
                              width=5,
                              justify="center",
                              padx=5,
                              pady=5)
    win.close_button.grid(row=1, column=1, padx=10, pady=10)

    win.mainloop()