本文整理汇总了Python中main_window.MainWindow.open_document方法的典型用法代码示例。如果您正苦于以下问题:Python MainWindow.open_document方法的具体用法?Python MainWindow.open_document怎么用?Python MainWindow.open_document使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类main_window.MainWindow
的用法示例。
在下文中一共展示了MainWindow.open_document方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IDE
# 需要导入模块: from main_window import MainWindow [as 别名]
# 或者: from main_window.MainWindow import open_document [as 别名]
class IDE(QMainWindow, IDEGeneric):
max_opacity = 1
min_opacity = 0.3
def __init__(self):
QWidget.__init__(self)
IDEGeneric.__init__(self)
self.setWindowTitle('NINJA-IDE {Ninja Is Not Just Another IDE}')
self.setWindowIcon(QIcon(resources.images['icon']))
self.setWindowState(Qt.WindowMaximized)
self.setMinimumSize(700, 500)
#Opactity
self.opacity = 1
#ToolBar
self._toolbar = QToolBar()
self._toolbar.setToolTip('Press and Drag to Move')
styles.set_style(self._toolbar, 'toolbar-default')
self.addToolBar(Qt.LeftToolBarArea, self._toolbar)
self._toolbar.setToolButtonStyle(Qt.ToolButtonIconOnly)
#StatusBar
self._status = StatusBar()
self._status.hide()
self.setStatusBar(self._status)
#Main Widgets
self.main = MainWindow(self)
self.setCentralWidget(self.main)
#Menu
menubar = self.menuBar()
styles.apply(menubar, 'menu')
file_ = menubar.addMenu('&File')
edit = menubar.addMenu('&Edit')
view = menubar.addMenu('&View')
project = menubar.addMenu('&Project')
self.pluginsMenu = menubar.addMenu('P&lugins')
about = menubar.addMenu('&About')
#The order of the icons in the toolbar is defined by this calls
self._menuFile = MenuFile(file_, self._toolbar, self.main)
self._menuView = MenuView(view, self, self.main)
self._menuEdit = MenuEdit(edit, self._toolbar, self.main, self._status)
self._menuProject = MenuProject(project, self._toolbar, self.main)
self._menuPlugins = MenuPlugins(self.pluginsMenu, self)
self._menuAbout = MenuAbout(about, self.main)
self.main.container.load_toolbar(self._toolbar)
self.main._central.actual_tab().obtain_editor().setFocus()
filenames, projects_path = core.cliparser.parse()
for filename in filenames:
self.main.open_document(filename)
for project_path in projects_path:
self.main.open_project_folder(project_path)
self.connect(self.main, SIGNAL("fileSaved(QString)"), self.show_status_message)
def show_status_message(self, message):
self._status.showMessage(message, 2000)
def add_toolbar_item(self, plugin, name, icon):
self._toolbar.addSeparator()
action = self._toolbar.addAction(QIcon(icon), name)
self.connect(action, SIGNAL("triggered()"), lambda: plugin.toolbarAction())
def closeEvent(self, event):
settings = QSettings('NINJA-IDE','Kunai')
if settings.value('Preferences/General/load_files', 2).toInt()[0]==2:
settings.setValue('Open_Files/projects',self.main.get_open_projects())
settings.setValue('Open_Files/tab1', self.main._central._tabs.get_open_files())
settings.setValue('Open_Files/tab2', self.main._central._tabs2.get_open_files())
else:
settings.setValue('Open_Files/projects',[])
if self.main._central.check_for_unsaved():
val = QMessageBox.question(self, 'Some changes were not saved',
'Do you want to exit anyway?', QMessageBox.Yes, QMessageBox.No)
if val == QMessageBox.No:
event.ignore()
else:
self.main._properties._treeProjects.close_open_projects()
else:
self.main._properties._treeProjects.close_open_projects()
def wheelEvent(self, event):
if event.modifiers() == Qt.AltModifier:
if event.delta() == 120 and self.opacity < self.max_opacity:
self.opacity += 0.1
elif event.delta() == -120 and self.opacity > self.min_opacity:
self.opacity -= 0.1
self.setWindowOpacity(self.opacity)
event.ignore()
else:
super(IDE, self).wheelEvent(event)