-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTk_Timestamp_Picker.py
64 lines (55 loc) · 2.77 KB
/
Tk_Timestamp_Picker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import tkinter as tk
from tkinter import ttk
class TimestampPicker(tk.Frame):
def __init__(self, parent):
tk.Frame.__init__(self, parent)
self.pack()
self.parent = parent
# Timestamp list variables
hh_values = tuple()
for i in range(0, 24):
hh_values += ("{:02d}".format(i),)
mm_values = tuple()
for i in range(0, 60):
mm_values += ("{:02d}".format(i),)
ss_values = tuple()
for i in range(0, 60):
ss_values += ("{:02d}".format(i),)
# Setup hh container
self.downlink_start_time_hh = tk.Frame(self.parent)
self.downlink_start_time_hh.pack(side=tk.LEFT, padx=10, pady=3)
self.downlink_start_time_hh_label = tk.Label(
self.downlink_start_time_hh, text="hh")
self.downlink_start_time_hh_label.pack(side=tk.TOP)
self.downlink_start_time_hh_current_option = tk.StringVar()
self.downlink_start_time_select_hh = ttk.Combobox(
self.downlink_start_time_hh, width=4, textvariable=self.downlink_start_time_hh_current_option,
state='readonly', values=hh_values)
self.downlink_start_time_select_hh.pack(side=tk.BOTTOM)
# Setup mm container
self.downlink_start_time_mm = tk.Frame(self.parent)
self.downlink_start_time_mm.pack(side=tk.LEFT, padx=10, pady=3)
self.downlink_start_time_mm_label = tk.Label(
self.downlink_start_time_mm, text="mm")
self.downlink_start_time_mm_label.pack()
self.downlink_start_time_mm_current_option = tk.StringVar()
self.downlink_start_time_select_mm = ttk.Combobox(
self.downlink_start_time_mm, width=4, textvariable=self.downlink_start_time_mm_current_option,
state='readonly', values=mm_values)
self.downlink_start_time_select_mm.pack(side=tk.BOTTOM)
# Setup ss container
self.downlink_start_time_ss = tk.Frame(self.parent)
self.downlink_start_time_ss.pack(side=tk.RIGHT, padx=10, pady=3)
self.downlink_start_time_ss_label = tk.Label(
self.downlink_start_time_ss, text="ss")
self.downlink_start_time_ss_label.pack(side=tk.TOP)
self.downlink_start_time_ss_current_option = tk.StringVar()
self.downlink_start_time_select_ss = ttk.Combobox(
self.downlink_start_time_ss, width=4, textvariable=self.downlink_start_time_ss_current_option,
state='readonly', values=ss_values)
self.downlink_start_time_select_ss.pack(side=tk.BOTTOM)
def get_timestamp(self):
hh = self.downlink_start_time_hh_current_option.get()
mm = self.downlink_start_time_mm_current_option.get()
ss = self.downlink_start_time_ss_current_option.get()
return f"{hh} {mm} {ss}" # return string