parent
4ac1c24371
commit
60d4080a02
@ -0,0 +1,4 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
/__pycache__
|
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/python-project.iml" filepath="$PROJECT_DIR$/.idea/python-project.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,43 @@
|
||||
from copy import deepcopy
|
||||
from algorithm import node, delete, merge, create
|
||||
import sys
|
||||
from Ui_PYdesign import Ui_PYdesigner
|
||||
from global_var import get_value, set_value
|
||||
import global_var
|
||||
from level import *
|
||||
import time
|
||||
|
||||
from PyQt5.QtWidgets import QApplication, QMainWindow
|
||||
|
||||
|
||||
def main():
|
||||
# print('Main')
|
||||
|
||||
global_var._init()
|
||||
|
||||
set_value('cur', {})
|
||||
|
||||
# 定义gui
|
||||
app = QApplication(sys.argv)
|
||||
MainWindow = QMainWindow()
|
||||
# ui = Ui_PYdesigner()
|
||||
set_value('ui', Ui_PYdesigner())
|
||||
# 初始化gui
|
||||
get_value('ui').setupUi(MainWindow)
|
||||
|
||||
MainWindow.setWindowTitle("python小组作业")
|
||||
|
||||
# 显示一下初始的数量
|
||||
create(0, 0)
|
||||
|
||||
get_value('ui').show_msm()
|
||||
|
||||
# 启用gui
|
||||
MainWindow.show()
|
||||
|
||||
# 系统结束
|
||||
sys.exit(app.exec_())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -0,0 +1,374 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PYdesigner</class>
|
||||
<widget class="QMainWindow" name="PYdesigner">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1056</width>
|
||||
<height>634</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>10</y>
|
||||
<width>111</width>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="center"><span style=" color:#000000;">level 0</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>-30</x>
|
||||
<y>70</y>
|
||||
<width>171</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="center"><span style=" color:#000000;">level 1</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextBrowser" name="textBrowser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>50</y>
|
||||
<width>51</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextBrowser" name="textBrowser_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>110</y>
|
||||
<width>51</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>-20</x>
|
||||
<y>150</y>
|
||||
<width>151</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="center">level 2</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextBrowser" name="textBrowser_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>160</y>
|
||||
<width>51</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>-20</x>
|
||||
<y>210</y>
|
||||
<width>151</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="center">level 3</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextBrowser" name="textBrowser_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>220</y>
|
||||
<width>51</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>-60</x>
|
||||
<y>-10</y>
|
||||
<width>361</width>
|
||||
<height>61</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="center"><span style=" font-size:12pt;">The number of level</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>270</y>
|
||||
<width>251</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line" name="line">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>250</x>
|
||||
<y>0</y>
|
||||
<width>20</width>
|
||||
<height>851</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>320</y>
|
||||
<width>111</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>创建</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="toolButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>410</y>
|
||||
<width>111</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>删除</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>19</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGraphicsView" name="graphicsView">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>20</y>
|
||||
<width>161</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::ActionsContextMenu</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="midLineWidth">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="interactive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sceneRect">
|
||||
<rectf>
|
||||
<x>0.000000000000000</x>
|
||||
<y>0.000000000000000</y>
|
||||
<width>0.000000000000000</width>
|
||||
<height>0.000000000000000</height>
|
||||
</rectf>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line" name="line_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>710</x>
|
||||
<y>-10</y>
|
||||
<width>20</width>
|
||||
<height>911</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextBrowser" name="textBrowser_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>730</x>
|
||||
<y>40</y>
|
||||
<width>311</width>
|
||||
<height>541</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>790</x>
|
||||
<y>0</y>
|
||||
<width>191</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="center">Terminal Information </p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGraphicsView" name="graphicsView_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
<y>20</y>
|
||||
<width>171</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGraphicsView" name="graphicsView_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>150</y>
|
||||
<width>161</width>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGraphicsView" name="graphicsView_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
<y>150</y>
|
||||
<width>171</width>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGraphicsView" name="graphicsView_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>290</y>
|
||||
<width>161</width>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGraphicsView" name="graphicsView_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
<y>290</y>
|
||||
<width>171</width>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGraphicsView" name="graphicsView_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>440</y>
|
||||
<width>161</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGraphicsView" name="graphicsView_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>470</x>
|
||||
<y>440</y>
|
||||
<width>171</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1056</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>pushButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>PYdesigner</receiver>
|
||||
<slot>creatlevel()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>166</x>
|
||||
<y>373</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>207</x>
|
||||
<y>376</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>toolButton_2</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>PYdesigner</receiver>
|
||||
<slot>delete()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>167</x>
|
||||
<y>463</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>211</x>
|
||||
<y>466</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>creatlevel()</slot>
|
||||
<slot>delete()</slot>
|
||||
</slots>
|
||||
</ui>
|
@ -0,0 +1,66 @@
|
||||
from copy import deepcopy
|
||||
from level import *
|
||||
from global_var import get_value
|
||||
maxlevel = 3 # 需要指明最大的level
|
||||
|
||||
|
||||
def search_path():
|
||||
pa = []
|
||||
cur = get_value('cur')
|
||||
for (lev, p) in cur.items():
|
||||
for i in p:
|
||||
pa.append(i.ImagePath)
|
||||
# print(pa)
|
||||
return pa
|
||||
|
||||
|
||||
def node(level): # 通过level指定需要的类型
|
||||
ui = get_value('ui')
|
||||
if level == 0:
|
||||
return level0()
|
||||
elif level == 1:
|
||||
return level1()
|
||||
elif level == 2:
|
||||
return level2()
|
||||
else:
|
||||
return level3()
|
||||
|
||||
|
||||
def delete():
|
||||
cur = get_value('cur')
|
||||
# delete操作
|
||||
ui = get_value('ui')
|
||||
cur.clear()
|
||||
ui.update0()
|
||||
ui.update1()
|
||||
ui.update2()
|
||||
ui.update3()
|
||||
ui.show_image()
|
||||
|
||||
|
||||
def merge(level):
|
||||
if level == maxlevel:
|
||||
return
|
||||
cur = get_value('cur')
|
||||
upcnts = len(cur[level]) // 3
|
||||
delcnts = len(cur[level]) % 3
|
||||
while len(cur[level]) != delcnts:
|
||||
cur[level].pop()
|
||||
if level + 1 <= maxlevel and upcnts > 0:
|
||||
create(upcnts, level + 1)
|
||||
|
||||
|
||||
def create(n, level): # create操作
|
||||
cur = get_value('cur')
|
||||
if level not in cur.keys():
|
||||
cur[level] = []
|
||||
for i in range(n):
|
||||
cur[level].append(node(level))
|
||||
ui = get_value('ui')
|
||||
ui.update0()
|
||||
ui.update1()
|
||||
ui.update2()
|
||||
ui.update3()
|
||||
merge(level)
|
||||
ui.show_image()
|
||||
# END
|
@ -0,0 +1,16 @@
|
||||
def _init(): # 初始化
|
||||
global _global_dict
|
||||
_global_dict = {}
|
||||
|
||||
|
||||
def set_value(key, value):
|
||||
# 定义一个全局变量
|
||||
_global_dict[key] = value
|
||||
|
||||
|
||||
def get_value(key):
|
||||
# 获得一个全局变量,不存在则提示读取对应变量失败
|
||||
try:
|
||||
return _global_dict[key]
|
||||
except:
|
||||
print('读取'+key+'失败\r\n')
|
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 178 KiB |
After Width: | Height: | Size: 271 KiB |
After Width: | Height: | Size: 51 KiB |
Loading…
Reference in new issue