0
我有一个组织设置问题,我需要帮助。这是我目前的文件夹结构。使用GUI加载Python模块
我想要做什么与包含功能指定AppCommands模块运行主UI。根据我想要运行该工具的应用程序。有没有办法使用另一个python文件,我可以加载gui和相关的应用程序命令moduel?所以当用户点击按钮时,它会调用更正应用程序命令。
所以说,比如我创建这样的伪代码
主要执行PY文件为Photoshop
Import photoshop.appcommands as cmds
Import GUI
Gui(cmds)
我怎么然后告诉我主要的GUI工具加载的Photoshop模块Python文件'AppCommands'何时运行?
应用#1代码:
def runTool():
msg = 'This is Notepad'
print msg
应用#2代码:
def runTool():
msg = 'This is Photoshop'
print msg
主UI代码:
import sys
import os
from PySide import QtGui, QtCore
import AppCommands as cmds
class MainWindow(QtGui.QMainWindow):
def __init__(self,parent=None):
super(MainWindow, self).__init__(parent)
self.uiButton = QtGui.QPushButton('Button', self)
# layout
grid = QtGui.QGridLayout()
grid.addWidget(self.uiButton, 3, 1)
main_widget = QtGui.QWidget()
main_widget.setLayout(grid)
self.setCentralWidget(main_widget)
self.uiButton.clicked.connect(self.browse_clicked)
# actions
def browse_clicked(self):
print 'Execute Command'
cmds.runTool()
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
ex = MainWindow()
ex.show()
sys.exit(app.exec_())
变化'进口AppCommands为cmds'为'进口{} XXXXX作为.AppCommands cmds' – eyllanesc
这是一个好主意,我怎么然后运行与指定模块的工具? – JokerMartini
你如何确定指定的模块? –