[go: up one dir, main page]

Menu

[r79]: / hour / trunk / spop_hour.py  Maximize  Restore  History

Download this file

177 lines (138 with data), 5.3 kB

  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
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/usr/bin/python
#-*- coding: UTF-8 -*-
from Tkinter import *
import tkFileDialog
import tkMessageBox
import codecs
import os
# Version Number
__version__ = "0.Alpha"
# Import the module to check if all files which are need are here
filecheck = __import__("lib/filecheck")
filecheck.FileCheck()
# Get the language module
lang_load = open(filecheck.language, "r")
_lang = lang_load.read()
lang_load = "share/language/lang_"+_lang
language = __import__(lang_load)
class Application:
# Command to destroy/quit the Application
def quit_window(self):
self.root.destroy()
# Command to open the AboutWindow
def about(self,whatever=None):
self.aboutwindow = AboutWindow()
# Command to calc
def calc(self,whatever=None):
self.start = self.start_date_entry.get()
print self.start
self.end = self.end_date_entry.get()
print self.end
self.total = int(self.end)-int(self.start)
if (self.total < 0):
self.total_date_entry.delete(0, END)
self.total_date_entry.insert(END, "WRONG")
else:
self.total_date_entry.delete(0, END)
self.total_date_entry.insert(END, self.total)
# About Window
def about_window(self, whatever=None):
# Import the about text in the right language
self.abouttext = "abouttext_"+_lang
self.abouttext = open("share/text/"+self.abouttext, "r")
self.abouttext = self.abouttext.read()
# Import the list of the developers
self.devellist = open("share/text/developers", "r")
self.devellist = self.devellist.read()
self.about_window = Toplevel()
self.about_window.title(language.aboutspop)
self.about_window.geometry("320x250+250+250")
self.about_frame = Frame(self.about_window)
self.about_frame.pack()
self.about_label = Label(self.about_frame, text="sPOP Hour Version "\
+__version__+"\n\n"+self.abouttext+"\n"+\
language.developer+"\n"+self.devellist)
self.about_label.pack()
self.about_button = Button(self.about_window, text=language.close,\
command=self.about_window.destroy)
self.about_button.pack(side=BOTTOM)
# The window
def __init__(self):
self.path = os.getenv("HOME")
self.root = Tk()
self.root.title("sPOP Hour")
self.root.protocol("WM_DELETE_WINDOW", self.quit_window)
self.root.geometry("600x350+100+100")
# The Menubar at the window
self.menubar = Menu(self.root)
# Menu called "File" in the Menubar
self.filemenu = Menu(self.menubar)
self.filemenu.add_command(label=language.path)
self.filemenu.add_separator()
self.filemenu.add_command(label=language.quit, command=self.quit_window)
# Menu called "Edit" in the Menubar
self.editmenu = Menu(self.menubar)
self.editmenu.add_command(label=language.copy)
self.editmenu.add_command(label=language.paste)
self.editmenu.add_command(label=language.cut)
# Menu called "Help" in the Menubar
self.helpmenu = Menu(self.menubar)
self.helpmenu.add_command(label=language.info, command=self.about_window)
# Add the "File" Menu to the Menubar
self.menubar.add_cascade(label=language._file, menu=self.filemenu)
self.menubar.add_cascade(label=language.edit, menu=self.editmenu)
self.menubar.add_cascade(label=language.help, menu=self.helpmenu)
# Display the Menubar in the window
self.root.config(menu=self.menubar)
# Path Entry
self.root_frame = Frame(self.root)
self.root_frame.pack(side=TOP, fill=X)
# Date Frame
self.date_frame = Frame(self.root_frame)
self.date_frame.pack(side=LEFT, fill=Y)
# Date Label
self.date_label = Label(self.date_frame, text="Date")
self.date_label.pack(side=TOP)
self.listbox_scrollbar = Scrollbar(self.date_frame, orient=VERTICAL)
#Date Listbox
self.date_listbox = Listbox(self.date_frame, yscrollcommand=self.listbox_scrollbar.set)
self.date_listbox.pack(side=LEFT, fill=Y, ipady=1)
self.listbox_scrollbar.pack(side=RIGHT, fill=Y)
self.listbox_scrollbar.config(command=self.date_listbox.yview)
# Start Frame
self.start_frame = Frame(self.root_frame)
self.start_frame.pack(side=LEFT, fill=Y)
# Start Label
self.start_label = Label(self.start_frame, text="START")
self.start_label.pack(side=TOP)
# Start Entries
self.start_date_entry = Entry(self.start_frame)
self.start_date_entry.pack()
# End Frame
self.end_frame = Frame(self.root_frame)
self.end_frame.pack(side=LEFT, fill=Y)
# End Label
self.end_label = Label(self.end_frame, text="END")
self.end_label.pack(side=TOP)
# End Entries
self.end_date_entry = Entry(self.end_frame)
self.end_date_entry.pack()
# Total Frame
self.total_frame = Frame(self.root_frame)
self.total_frame.pack(side=LEFT, fill=Y)
# Total Label
self.total_label = Label(self.total_frame, text="Total")
self.total_label.pack(side=TOP)
# Total Entries
self.total_date_entry = Entry(self.total_frame)
self.total_date_entry.pack()
self.list = range(1, 32)
for day in self.list:
self.date_listbox.insert(END, day)
# Hotkeys
self.root.bind("<Control-L>",self.calc)
self.root.bind("<Control-l>",self.calc)
# Command to show window
self.root.mainloop()
if __name__ == "__main__":
Application()