Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 72c11a8

Browse files
Update main.py
1 parent 539a078 commit 72c11a8

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

‎Calendar/main.py‎

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,30 @@
11
#!/usr/bin/python3
2-
# Calendar v1.0
32
#
43

54
from PyQt5.QtWidgets import *
65
from PyQt5.QtCore import *
76
from PyQt5.QtGui import *
7+
from PyQt5.uic import loadUi
88
import sys
99

10-
class Window(QWidget):
10+
class Window(QMainWindow):
1111
def __init__(self):
1212
super(Window,self).__init__()
13-
global date
14-
self.setWindowTitle("Calendar")
15-
self.setGeometry(500,100,500,400)
16-
self.setFixedSize(500,400)
17-
cal = QCalendarWidget(self)
18-
cal.setGridVisible(True)
19-
cal.move(50,30)
20-
cal.clicked[QDate].connect(self.show_date)
21-
self.lbl = QLabel(self)
22-
self.lbl.setFont(QFont("Arial",18))
23-
self.lbl.setGeometry(145,255,400,100)
24-
# self.lbl.move(170,300)
25-
date = cal.selectedDate()
26-
self.lbl.setText(date.toString("yyyy:MM:dd"))
27-
28-
def show_date(self,date):
29-
self.lbl.setText(date.toString())
13+
loadUi("form.ui",self)
14+
self.setWindowTitle("تقویم")
15+
self.calendar.selectionChanged.connect(self.change_date)
16+
17+
def change_date(self):
18+
date = self.calendar.selectedDate()
19+
self.label.setText(f"تاریخ: {str(date.toPyDate())}")
3020

3121

3222
def main():
33-
# Calendar v1.0
3423
app = QApplication(sys.argv)
35-
app.setApplicationName("Calendar")
36-
app.setApplicationVersion("v1.0")
3724
window = Window()
3825
window.show()
39-
app.exec_()
26+
sys.exit(app.exec_())
4027

4128
if __name__ == "__main__":
4229
main()
30+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /