Skip to content

Commit 45bf2c8

Browse files
authored
Update Weather.py
Set a fixed size for the windows
1 parent f46379d commit 45bf2c8

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Weather.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
# @Project : Weather
55
# @Product : Pycharm v2022.3.3
66
# @File : Weather.py
7-
# @Edit : 2024-3-9 9:56
8-
# @Version : V2.0
97
import datetime
108
import json
119
import locale
@@ -377,33 +375,29 @@ def __init__(self, city):
377375
layout = QtWidgets.QHBoxLayout()
378376
self.setWindowTitle(f"五日天气 - {city}市")
379377
self.setLayout(layout)
378+
self.setFixedSize(800, 400)
380379
self.resize(800, 400)
381380
self.setWindowIcon(QtGui.QIcon("Weather.png"))
382381
font = QtGui.QFont()
383382
font.setPointSize(12)
384383
font.setFamily("荆南麦圆体")
385384
self.setFont(font)
386-
387385
self.label = QtWidgets.QLabel()
388386
layout.addWidget(self.label)
389387
self.label.setText(info[0])
390388
self.label.setAlignment(QtCore.Qt.AlignLeft | Qt.AlignVCenter)
391-
392389
self.label1 = QtWidgets.QLabel()
393390
layout.addWidget(self.label1)
394391
self.label1.setText(info[1])
395392
self.label1.setAlignment(QtCore.Qt.AlignLeft | Qt.AlignVCenter)
396-
397393
self.label2 = QtWidgets.QLabel()
398394
layout.addWidget(self.label2)
399395
self.label2.setText(info[2])
400396
self.label2.setAlignment(QtCore.Qt.AlignLeft | Qt.AlignVCenter)
401-
402397
self.label3 = QtWidgets.QLabel()
403398
layout.addWidget(self.label3)
404399
self.label3.setText(info[3])
405400
self.label3.setAlignment(QtCore.Qt.AlignLeft | Qt.AlignVCenter)
406-
407401
self.label4 = QtWidgets.QLabel()
408402
layout.addWidget(self.label4)
409403
self.label4.setText(info[4])
@@ -435,6 +429,7 @@ def __init__(self, parent=None):
435429
super(Weather, self).__init__(parent)
436430
self.setupUi(self)
437431
self.InitializeUi()
432+
self.setFixedSize(600, 500)
438433

439434
def InitializeUi(self):
440435
"""
@@ -515,6 +510,9 @@ def getWeather_5(self):
515510
JSONDecodeError: If there is an error decoding the JSON response.
516511
Exception: If there is an unknown error.
517512
513+
Examples:
514+
This function is typically called when the user wants to query the weather.
515+
It retrieves the user input, performs a weather query, and displays the result.
518516
"""
519517
city = self.lineEdit.text()
520518
err_msg = ""

0 commit comments

Comments
 (0)