![](/uploads/image/0610.jpg)
通过PyQt5编写天⽓预报界⾯程序1:通过Qt Designer设计WeatherWin.ui界⾯ a:到Library/bin下的Qt设计器,点击designer,启动Qt设计器
b:启动之后是这样的
标题
c:新建窗体中选第⼀个,然后创建好后如下。
d:上图界⾯的所有控件详细清单如下:
e:weatherComboBox中的详细信息如下:
f:定义好两个按钮的信号与槽函数如下
g:两个槽函数要⾃⼰定义好,如下
h:WeatherWin.ui界⾯代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>581</width>
<height>358</height>桂林漓江游船怎么坐最合适
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<widget class="QPushButton" name="QueryBtn"> <property name="geometry">
<rect>
<x>100</x>
<y>310</y>
<width>75</width>
<height>23</height>
</rect>
御温泉度假村攻略
</property>
<property name="text">
<string>查询</string>
</property>
</widget>
<widget class="QPushButton" name="clearBtn"> <property name="geometry">
<property name="geometry">
<rect>
<x>420</x>
<y>310</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
承德避暑山庄一日游
<string>清空</string>
</property>
</widget>
<widget class="QTextEdit" name="resultText">
<property name="geometry">
<rect>
<x>50</x>
<y>110</y>
<width>491</width>
<height>181</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>10</y>
<width>81</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>查询城市天⽓</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>40</x>
<y>40</y>
<width>61</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>城市</string>
</property>
</widget>
<widget class="QComboBox" name="weatherComboBox"> <property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
报旅行团旅游<rect>
<x>100</x>
<y>40</y>
<width>361</width>
<height>22</height>
</rect>
</property>
<property name="editable">
<bool>true</bool>
</property>
<property name="duplicatesEnabled">
<bool>true</bool>
</property>
</property>
<item>
<property name="text">
<string>上海</string>
</property>
</item>
<item>
<property name="text">
<string>北京</string>
</property>
</item>
<item>
<property name="text">
<string>天津</string>
</property>
</item>
<item>
<property name="text">
<string>桂林</string>
</property>
</item>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>QueryBtn</sender> <signal>clicked()</signal>
<receiver>Dialog</receiver> <slot>QueryWeather()</slot> <hints>
<hint type="sourcelabel">
<x>121</x>
<y>314</y>
</hint>
<hint type="destinationlabel"> <x>219</x>
<y>335</y>
</hint>
</hints>
</connection>
<connection>
<sender>clearBtn</sender> <signal>clicked()</signal>
<receiver>Dialog</receiver> <slot>clearResult()</slot>
<hints>
<hint type="sourcelabel">
<x>437</x>
<y>319</y>
</hint>
<hint type="destinationlabel"> <x>512</x>
<y>338</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>QueryWeather()</slot> <slot>clearResult()</slot>
</ui>