# create the main window (titlebar and frame)
# https://ttkthemes.readthedocs.io/en/latest/themes.html
main_window = ThemedTk(theme="equilux")
main_window.title("APOD_Linux config")
main_window.columnconfigure(0, weight=1)
main_window.rowconfigure(0, weight=1)
main_window.resizable(False, False)

# set main womdow's icon
icon = PhotoImage(
    file = "/usr/share/icons/hicolor/128x128/apps/apod_linux_icon.png")
main_window.iconphoto(False, icon)

# register the validate function with the main window (%S is the user input,
# whether typed or pasted)
validate_func = (main_window.register(validate), "%S")

# set variables/defults
# NB: needs to be done after main window creation
var_enabled = IntVar()
var_enabled.set(1)
var_delay = IntVar()
var_delay.set(30)
var_caption = IntVar()
var_caption.set(1)
var_color_r = IntVar()
var_color_r.set(255)
var_color_g = IntVar()
var_color_g.set(255)
var_color_b = IntVar()
var_color_b.set(255)
Esempio n. 2
0
    parts_number = len(parts)

    if parts_number > 2:
        return False

    if parts_number > 1 and parts[1]:
        if not parts[1].isdecimal() or len(parts[1]) > 2:
            return False

    if parts_number > 0 and parts[0]:  # don't check empty string
        if not parts[0].isdecimal() or len(parts[0]) > 8:
            # print('wrong first part')
            return False

    return True


# Register is to check every keystroke the character enters
# Then checks if the keystroke is valid for that specific function
charactervalidation = root.register(only_character_input)
numbervalidation = root.register(only_numeric_input)
timevalidation = root.register(only_time_input)

numberPlaceHolder = PlaceholderEntry(testframe, "Number", "number")
numberPlaceHolder.grid(row=1, column=1, columnspan=3, pady=10)
timePlaceHolder = PlaceholderEntry(testframe, "Time", "time")
timePlaceHolder.grid(row=2, column=1, padx=100, pady=10)
charPlaceHolder = PlaceholderEntry(testframe, "Character", "character")
charPlaceHolder.grid(row=3, column=1, pady=10)

mainloop()