Skip to content

Commit

Permalink
Implemented the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
basedafdev committed Jul 9, 2018
1 parent 9033fba commit 817991f
Show file tree
Hide file tree
Showing 3,314 changed files with 70,772 additions and 67,159 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 4 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

from calendar_ui import DatePicker, CalendarWidget
Binary file added __pycache__/calendar_data.cpython-36.pyc
Binary file not shown.
Binary file added __pycache__/calendar_ui.cpython-36.pyc
Binary file not shown.
Binary file modified __pycache__/company.cpython-36.pyc
Binary file not shown.
Binary file modified __pycache__/directory.cpython-36.pyc
Binary file not shown.
Binary file modified __pycache__/load_files.cpython-36.pyc
Binary file not shown.
Binary file added back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
115 changes: 115 additions & 0 deletions calculator.kv
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@

<CustButton@Button>
font_size: 32
background_color: .55,.5,.4,.6
<CalcGridLayout>:
id: calculator

rows: 5
cols: 3
padding: 30
spacing: 10

Label:

text: calculator.fake_init()
font_size: 20
canvas.before:

BoxLayout:
Image :
source: 'back.png'
allow_stretch: True
keep_ratio: False
BoxLayout:
DatePicker:

id: date
BoxLayout:

CustButton:
text: "low to high"
font_size: 20
CustButton:
text: "high to low"
font_size: 20
BoxLayout:
CustButton:
text: "low to high"
font_size: 20
CustButton:
text: "high to low"
font_size: 20

BoxLayout:
CustButton:
text: "Set Date"
on_press:
calculator.set_date(date)
one.text = calculator.top_ten("0")
two.text = calculator.top_ten("1")
three.text = calculator.top_ten("2")
four.text = calculator.top_ten("3")
five.text = calculator.top_ten("4")
six.text = calculator.top_ten("5")
seven.text = calculator.top_ten("6")
eight.text = calculator.top_ten("7")
nine.text = calculator.top_ten("8")



BoxLayout:
CustButton:
id: one
text: calculator.top_ten("0")
on_press: calculator.pull_up_ticker(one)
background_color: (0, 0.6, 0.2, 1.0)
font: 10
BoxLayout:
CustButton:
id: two
text: calculator.top_ten("1")
on_press: calculator.pull_up_ticker(two)
background_color: (0, 0.6, 0, 1.0)
BoxLayout:
CustButton:
id: three
text: calculator.top_ten("2")
on_press: calculator.pull_up_ticker(three)
background_color: (.4, 0.6, 0, 1.0)
BoxLayout:
CustButton:
id: four
text: calculator.top_ten("3")
on_press: calculator.pull_up_ticker(four)
background_color: (.6, 0.8, 0, 1.0)
BoxLayout:
CustButton:
id: five
text: calculator.top_ten("4")
on_press: calculator.pull_up_ticker(five)
background_color: (.8, 0.8, 0, 1.0)
BoxLayout:
CustButton:
id: six
text: calculator.top_ten("5")
on_press: calculator.pull_up_ticker(six)
background_color: (.8, 0.6, 0, 1.0)
BoxLayout:
CustButton:
id: seven
text: calculator.top_ten("6")
on_press: calculator.pull_up_ticker(seven)
background_color: (1, 0.8, 0, 1.0)
BoxLayout:
CustButton:
id: eight
text: calculator.top_ten("7")
on_press: calculator.pull_up_ticker(eight)
background_color: (1, 0.6, .2, 1.0)
BoxLayout:
CustButton:
id: nine
text: calculator.top_ten("8")
on_press: calculator.pull_up_ticker(nine)
background_color: (1, 0.4, 0, 1.0)
150 changes: 150 additions & 0 deletions calendar_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

###########################################################
# KivyCalendar (X11/MIT License)
# Calendar & Date picker widgets for Kivy (http://kivy.org)
# https://bitbucket.org/xxblx/kivycalendar
#
# Oleg Kozlov (xxblx), 2015
# https://xxblx.bitbucket.org/
###########################################################


from calendar import month_name, day_abbr, Calendar, monthrange
from datetime import datetime
from locale import getdefaultlocale
from calendar import timegm as TimeEncoding
def get_month_names():
""" Return list with months names """

result = []
# If it possible get months names in system language
try:
with TimeEncoding("%s.%s" % getdefaultlocale()) as time_enc:
for i in range(1, 13):
result.append(month_name[i].decode(time_enc))

return result

except:
return get_month_names_eng()

def get_month_names_eng():
""" Return list with months names in english """

result = []
for i in range(1, 13):
result.append(month_name[i])

return result

def get_days_abbrs():
""" Return list with days abbreviations """

result = []
# If it possible get days abbrs in system language
try:
with TimeEncoding("%s.%s" % getdefaultlocale()) as time_enc:
for i in range(7):
result.append(day_abbr[i].decode(time_enc))
except:
for i in range(7):
result.append(day_abbr[i])

return result

def calc_quarter(y, m):
""" Calculate previous and next month """

# Previous / Next month's year number and month number
prev_y = y
prev_m = m - 1
next_y = y
next_m = m + 1

if m == 1:
prev_m = 12
prev_y = y - 1
elif m == 12:
next_m = 1
next_y = y + 1

return [(prev_y, prev_m), (y, m), (next_y, next_m)]

def get_month(y, m):
"""
Return list of month's weeks, which day
is a turple (<month day number>, <weekday number>)
"""

cal = Calendar()
month = cal.monthdays2calendar(y, m)

# Add additional num to every day which mark from
# this or from other day that day numer
for week in range(len(month)):
for day in range(len(month[week])):
_day = month[week][day]
if _day[0] == 0:
this = 0
else:
this = 1
_day = (_day[0], _day[1], this)
month[week][day] = _day

# Days numbers of days from preious and next monthes
# marked as 0 (zero), replace it with correct numbers
# If month include 4 weeks it hasn't any zero
if len(month) == 4:
return month

quater = calc_quarter(y, m)

# Zeros in first week
fcount = 0
for i in month[0]:
if i[0] == 0:
fcount += 1

# Zeros in last week
lcount = 0
for i in month[-1]:
if i[0] == 0:
lcount += 1

if fcount:
# Last day of prev month
n = monthrange(quater[0][0], quater[0][1])[1]

for i in range(fcount):
month[0][i] = (n - (fcount - 1 - i), i, 0)

if lcount:
# First day of next month
n = 1

for i in range(lcount):
month[-1][-lcount + i] = (n + i, 7 - lcount + i, 0)

return month

def get_quarter(y, m):
""" Get quarter where m is a middle month """

result = []
quarter = calc_quarter(y, m)
for i in quarter:
result.append(get_month(i[0], i[1]))

return result

def today_date_list():
""" Return list with today date """

return [datetime.now().day, datetime.now().month, datetime.now().year]

def today_date():
""" Return today date dd.mm.yyyy like 28.02.2015 """

return datetime.now().strftime("%d.%m.%Y")
Loading

0 comments on commit 817991f

Please sign in to comment.