Skip to content

Commit a2b569e

Browse files
committed
First working version
Set focus when timer has stopped Create tomato timer class Restore when minimized Add tests Add notification sound Add icon and window title Save window position Add "About" window Add qt designer ui file for main window Rename package Move media to directory Fix tests Create readme
1 parent c985209 commit a2b569e

21 files changed

+964
-0
lines changed

CherryTomato/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import os
2+
3+
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
4+
MEDIA_DIR = os.path.join(BASE_DIR, 'media')
5+
APP_ICON = os.path.join(MEDIA_DIR, 'icon.png')

CherryTomato/__main__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import main

CherryTomato/about.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from PyQt5 import QtWidgets
2+
from PyQt5.QtGui import QIcon
3+
4+
from CherryTomato import APP_ICON
5+
from .about_ui import Ui_About
6+
7+
8+
class About(QtWidgets.QWidget, Ui_About):
9+
def __init__(self):
10+
super().__init__()
11+
12+
self.setupUi(self)
13+
14+
self.setWindowIcon(QIcon(APP_ICON))

CherryTomato/about_ui.py

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Form implementation generated from reading ui file 'about_ui.ui'
4+
#
5+
# Created by: PyQt5 UI code generator 5.13.1
6+
#
7+
# WARNING! All changes made in this file will be lost!
8+
9+
10+
from PyQt5 import QtCore, QtGui, QtWidgets
11+
12+
13+
class Ui_About(object):
14+
def setupUi(self, About):
15+
About.setObjectName("About")
16+
About.resize(402, 222)
17+
self.verticalLayout = QtWidgets.QVBoxLayout(About)
18+
self.verticalLayout.setObjectName("verticalLayout")
19+
self.label_title = QtWidgets.QLabel(About)
20+
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum)
21+
sizePolicy.setHorizontalStretch(0)
22+
sizePolicy.setVerticalStretch(0)
23+
sizePolicy.setHeightForWidth(self.label_title.sizePolicy().hasHeightForWidth())
24+
self.label_title.setSizePolicy(sizePolicy)
25+
font = QtGui.QFont()
26+
font.setPointSize(13)
27+
font.setBold(True)
28+
font.setWeight(75)
29+
self.label_title.setFont(font)
30+
self.label_title.setText("CherryTomato")
31+
self.label_title.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignTop)
32+
self.label_title.setObjectName("label_title")
33+
self.verticalLayout.addWidget(self.label_title)
34+
self.label_text = QtWidgets.QLabel(About)
35+
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.MinimumExpanding)
36+
sizePolicy.setHorizontalStretch(0)
37+
sizePolicy.setVerticalStretch(1)
38+
sizePolicy.setHeightForWidth(self.label_text.sizePolicy().hasHeightForWidth())
39+
self.label_text.setSizePolicy(sizePolicy)
40+
self.label_text.setTextFormat(QtCore.Qt.RichText)
41+
self.label_text.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
42+
self.label_text.setWordWrap(True)
43+
self.label_text.setOpenExternalLinks(True)
44+
self.label_text.setObjectName("label_text")
45+
self.verticalLayout.addWidget(self.label_text)
46+
self.label_copyright = QtWidgets.QLabel(About)
47+
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum)
48+
sizePolicy.setHorizontalStretch(0)
49+
sizePolicy.setVerticalStretch(0)
50+
sizePolicy.setHeightForWidth(self.label_copyright.sizePolicy().hasHeightForWidth())
51+
self.label_copyright.setSizePolicy(sizePolicy)
52+
self.label_copyright.setText("Copyright © 2019 yakimka")
53+
self.label_copyright.setAlignment(QtCore.Qt.AlignBottom|QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft)
54+
self.label_copyright.setObjectName("label_copyright")
55+
self.verticalLayout.addWidget(self.label_copyright)
56+
57+
self.retranslateUi(About)
58+
QtCore.QMetaObject.connectSlotsByName(About)
59+
60+
def retranslateUi(self, About):
61+
_translate = QtCore.QCoreApplication.translate
62+
About.setWindowTitle(_translate("About", "About CherryTomato"))
63+
self.label_text.setText(_translate("About", "<html><head/><body><p>CherryTomato is a simple tomato timer app.</p><p>It\'s written in Python 3 using PyQt5.</p><p>Project page: <a href=\"https://github.com/yakimka/CherryTomato\"><span style=\" text-decoration: underline; color:#4877b1;\">https://github.com/yakimka/CherryTomato</span></a></p></body></html>"))

CherryTomato/about_ui.ui

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>About</class>
4+
<widget class="QWidget" name="About">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>402</width>
10+
<height>222</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>About CherryTomato</string>
15+
</property>
16+
<layout class="QVBoxLayout" name="verticalLayout">
17+
<item>
18+
<widget class="QLabel" name="label_title">
19+
<property name="sizePolicy">
20+
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
21+
<horstretch>0</horstretch>
22+
<verstretch>0</verstretch>
23+
</sizepolicy>
24+
</property>
25+
<property name="font">
26+
<font>
27+
<pointsize>13</pointsize>
28+
<weight>75</weight>
29+
<bold>true</bold>
30+
</font>
31+
</property>
32+
<property name="text">
33+
<string notr="true">CherryTomato</string>
34+
</property>
35+
<property name="alignment">
36+
<set>Qt::AlignHCenter|Qt::AlignTop</set>
37+
</property>
38+
</widget>
39+
</item>
40+
<item>
41+
<widget class="QLabel" name="label_text">
42+
<property name="sizePolicy">
43+
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
44+
<horstretch>0</horstretch>
45+
<verstretch>1</verstretch>
46+
</sizepolicy>
47+
</property>
48+
<property name="text">
49+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;CherryTomato is a simple tomato timer app.&lt;/p&gt;&lt;p&gt;It's written in Python 3 using PyQt5.&lt;/p&gt;&lt;p&gt;Project page: &lt;a href=&quot;https://github.com/yakimka/CherryTomato&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#4877b1;&quot;&gt;https://github.com/yakimka/CherryTomato&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
50+
</property>
51+
<property name="textFormat">
52+
<enum>Qt::RichText</enum>
53+
</property>
54+
<property name="alignment">
55+
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
56+
</property>
57+
<property name="wordWrap">
58+
<bool>true</bool>
59+
</property>
60+
<property name="openExternalLinks">
61+
<bool>true</bool>
62+
</property>
63+
</widget>
64+
</item>
65+
<item>
66+
<widget class="QLabel" name="label_copyright">
67+
<property name="sizePolicy">
68+
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
69+
<horstretch>0</horstretch>
70+
<verstretch>0</verstretch>
71+
</sizepolicy>
72+
</property>
73+
<property name="text">
74+
<string notr="true">Copyright © 2019 yakimka</string>
75+
</property>
76+
<property name="alignment">
77+
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
78+
</property>
79+
</widget>
80+
</item>
81+
</layout>
82+
</widget>
83+
<resources/>
84+
<connections/>
85+
</ui>

CherryTomato/main.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python3
2+
3+
import sys
4+
5+
from PyQt5 import Qt
6+
7+
from CherryTomato.main_window import TomatoTimerWindow
8+
9+
app = Qt.QApplication(sys.argv)
10+
11+
watch = TomatoTimerWindow()
12+
watch.show()
13+
14+
app.exec_()

CherryTomato/main_ui.py

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Form implementation generated from reading ui file 'main_ui.ui'
4+
#
5+
# Created by: PyQt5 UI code generator 5.13.1
6+
#
7+
# WARNING! All changes made in this file will be lost!
8+
9+
10+
from PyQt5 import QtCore, QtGui, QtWidgets
11+
12+
13+
class Ui_MainWindow(object):
14+
def setupUi(self, MainWindow):
15+
MainWindow.setObjectName("MainWindow")
16+
MainWindow.resize(800, 600)
17+
self.centralwidget = QtWidgets.QWidget(MainWindow)
18+
self.centralwidget.setObjectName("centralwidget")
19+
self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
20+
self.verticalLayout.setContentsMargins(15, 15, 15, 60)
21+
self.verticalLayout.setObjectName("verticalLayout")
22+
self.horizontalLayout = QtWidgets.QHBoxLayout()
23+
self.horizontalLayout.setContentsMargins(-1, -1, -1, 40)
24+
self.horizontalLayout.setObjectName("horizontalLayout")
25+
self.progress = QRoundProgressBar(self.centralwidget)
26+
self.progress.setMinimumSize(QtCore.QSize(200, 200))
27+
self.progress.setObjectName("progress")
28+
self.horizontalLayout.addWidget(self.progress)
29+
self.verticalLayout.addLayout(self.horizontalLayout)
30+
self.button = QRoundPushbutton(self.centralwidget)
31+
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
32+
sizePolicy.setHorizontalStretch(0)
33+
sizePolicy.setVerticalStretch(0)
34+
sizePolicy.setHeightForWidth(self.button.sizePolicy().hasHeightForWidth())
35+
self.button.setSizePolicy(sizePolicy)
36+
self.button.setMinimumSize(QtCore.QSize(40, 40))
37+
self.button.setMaximumSize(QtCore.QSize(40, 40))
38+
self.button.setBaseSize(QtCore.QSize(0, 0))
39+
self.button.setStyleSheet("background-color: rgb(255, 37, 51);\n"
40+
"background-image: url(\"./play.png\");\n"
41+
"border: 1px solid rgb(255, 37, 51);\n"
42+
"border-radius: 20px;")
43+
self.button.setText("")
44+
self.button.setFlat(True)
45+
self.button.setObjectName("button")
46+
self.verticalLayout.addWidget(self.button, 0, QtCore.Qt.AlignHCenter)
47+
MainWindow.setCentralWidget(self.centralwidget)
48+
self.menuBar = QtWidgets.QMenuBar(MainWindow)
49+
self.menuBar.setGeometry(QtCore.QRect(0, 0, 800, 30))
50+
self.menuBar.setObjectName("menuBar")
51+
self.menuFile = QtWidgets.QMenu(self.menuBar)
52+
self.menuFile.setObjectName("menuFile")
53+
MainWindow.setMenuBar(self.menuBar)
54+
self.actionAbout = QtWidgets.QAction(MainWindow)
55+
self.actionAbout.setObjectName("actionAbout")
56+
self.menuFile.addAction(self.actionAbout)
57+
self.menuBar.addAction(self.menuFile.menuAction())
58+
59+
self.retranslateUi(MainWindow)
60+
QtCore.QMetaObject.connectSlotsByName(MainWindow)
61+
62+
def retranslateUi(self, MainWindow):
63+
_translate = QtCore.QCoreApplication.translate
64+
MainWindow.setWindowTitle(_translate("MainWindow", "CherryTomato"))
65+
self.menuFile.setTitle(_translate("MainWindow", "File"))
66+
self.actionAbout.setText(_translate("MainWindow", "About"))
67+
from CherryTomato.widget import QRoundProgressBar, QRoundPushbutton

CherryTomato/main_ui.ui

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>MainWindow</class>
4+
<widget class="QMainWindow" name="MainWindow">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>800</width>
10+
<height>600</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>CherryTomato</string>
15+
</property>
16+
<widget class="QWidget" name="centralwidget">
17+
<layout class="QVBoxLayout" name="verticalLayout">
18+
<property name="leftMargin">
19+
<number>15</number>
20+
</property>
21+
<property name="topMargin">
22+
<number>15</number>
23+
</property>
24+
<property name="rightMargin">
25+
<number>15</number>
26+
</property>
27+
<property name="bottomMargin">
28+
<number>60</number>
29+
</property>
30+
<item>
31+
<layout class="QHBoxLayout" name="horizontalLayout">
32+
<property name="bottomMargin">
33+
<number>40</number>
34+
</property>
35+
<item>
36+
<widget class="QRoundProgressBar" name="progress" native="true">
37+
<property name="minimumSize">
38+
<size>
39+
<width>200</width>
40+
<height>200</height>
41+
</size>
42+
</property>
43+
</widget>
44+
</item>
45+
</layout>
46+
</item>
47+
<item alignment="Qt::AlignHCenter">
48+
<widget class="QRoundPushbutton" name="button">
49+
<property name="sizePolicy">
50+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
51+
<horstretch>0</horstretch>
52+
<verstretch>0</verstretch>
53+
</sizepolicy>
54+
</property>
55+
<property name="minimumSize">
56+
<size>
57+
<width>40</width>
58+
<height>40</height>
59+
</size>
60+
</property>
61+
<property name="maximumSize">
62+
<size>
63+
<width>40</width>
64+
<height>40</height>
65+
</size>
66+
</property>
67+
<property name="baseSize">
68+
<size>
69+
<width>0</width>
70+
<height>0</height>
71+
</size>
72+
</property>
73+
<property name="styleSheet">
74+
<string notr="true">background-color: rgb(255, 37, 51);
75+
background-image: url(&quot;./play.png&quot;);
76+
border: 1px solid rgb(255, 37, 51);
77+
border-radius: 20px;</string>
78+
</property>
79+
<property name="text">
80+
<string/>
81+
</property>
82+
<property name="flat">
83+
<bool>true</bool>
84+
</property>
85+
</widget>
86+
</item>
87+
</layout>
88+
</widget>
89+
<widget class="QMenuBar" name="menuBar">
90+
<property name="geometry">
91+
<rect>
92+
<x>0</x>
93+
<y>0</y>
94+
<width>800</width>
95+
<height>30</height>
96+
</rect>
97+
</property>
98+
<widget class="QMenu" name="menuFile">
99+
<property name="title">
100+
<string>File</string>
101+
</property>
102+
<addaction name="actionAbout"/>
103+
</widget>
104+
<addaction name="menuFile"/>
105+
</widget>
106+
<action name="actionAbout">
107+
<property name="text">
108+
<string>About</string>
109+
</property>
110+
</action>
111+
</widget>
112+
<customwidgets>
113+
<customwidget>
114+
<class>QRoundProgressBar</class>
115+
<extends>QWidget</extends>
116+
<header>tomato_timer.widget</header>
117+
<container>1</container>
118+
</customwidget>
119+
<customwidget>
120+
<class>QRoundPushbutton</class>
121+
<extends>QPushButton</extends>
122+
<header>tomato_timer.widget</header>
123+
</customwidget>
124+
</customwidgets>
125+
<resources/>
126+
<connections/>
127+
</ui>

0 commit comments

Comments
 (0)