OpenStructure
Loading...
Searching...
No Matches
widget_example.py

Shows how to add a fancy python widget to the right side bar.

1#------------------------------------------------------------------------------
2# This file is part of the OpenStructure project <www.openstructure.org>
3#
4# Copyright (C) 2008-2020 by the OpenStructure authors
5#
6# This library is free software; you can redistribute it and/or modify it under
7# the terms of the GNU Lesser General Public License as published by the Free
8# Software Foundation; either version 3.0 of the License, or (at your option)
9# any later version.
10# This library is distributed in the hope that it will be useful, but WITHOUT
11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13# details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with this library; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18#------------------------------------------------------------------------------
19
20from ost import gui
21
22from PyQt5 import QtCore, QtGui, QtWidgets
23
24#Get Panels (Class which manages widgets)
25panels=gui.GostyApp.Instance().perspective.panels
26
27#Create Widget
28my_awesome_widget = QtWidgets.QWidget()
29layout = QtWidgets.QVBoxLayout()
30layout.addWidget(QtWidgets.QPushButton('I dont do anything'))
31layout.addWidget(QtWidgets.QPushButton('I do even less'))
32my_awesome_widget.setLayout(layout)
33
34#Wrap widget to Qt Widget
35wid=gui.Widget(my_awesome_widget)
36
37#Add Widget to widget pool
38panels.AddWidgetToPool("Widget that doesnt do a thing", wid)
39
40#Add Widget to right panel
41panels.AddWidget(gui.PanelPosition.RIGHT_PANEL,wid,False)
42