本文整理匯總了Python中PyQt5.QtWidgets.QWidget.__init__方法的典型用法代碼示例。如果您正苦於以下問題:Python QWidget.__init__方法的具體用法?Python QWidget.__init__怎麽用?Python QWidget.__init__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.QWidget
的用法示例。
在下文中一共展示了QWidget.__init__方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QWidget [as 別名]
# 或者: from PyQt5.QtWidgets.QWidget import __init__ [as 別名]
def __init__(self, parent=None):
"""Initialize the GUI
Parameters
----------
self : SWindCond
A SWindCond widget
"""
# Build the interface according to the .ui file
QWidget.__init__(self, parent)
self.setupUi(self)
self.machine = None
# Connect the widget
self.b_mmf.clicked.connect(self.plot_mmf)
示例2: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QWidget [as 別名]
# 或者: from PyQt5.QtWidgets.QWidget import __init__ [as 別名]
def __init__(self, parent=None):
"""Initialize the widget
"""
# Main widget setup
QWidget.__init__(self, parent)
self.u = gui_option.unit
self.setTitle(self.tr("Output"))
self.setMinimumSize(QSize(200, 0))
self.setObjectName("g_output")
self.layout = QVBoxLayout(self)
self.layout.setObjectName("layout")
# The widget is composed of 3 QLabel in a vertical layout
self.out_Sbar = QLabel(self)
self.out_Sbar.setObjectName("out_Sbar")
self.layout.addWidget(self.out_Sbar)
self.out_Sslot = QLabel(self)
self.out_Sslot.setObjectName("out_Sslot")
self.layout.addWidget(self.out_Sslot)
self.out_ratio = QLabel(self)
self.out_ratio.setMinimumSize(QSize(140, 0))
self.out_ratio.setObjectName("out_ratio")
self.layout.addWidget(self.out_ratio)
示例3: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QWidget [as 別名]
# 或者: from PyQt5.QtWidgets.QWidget import __init__ [as 別名]
def __init__(self, parent, initial_time, label, on_update=lambda x: x):
"""
Args:
parent: ColorMapWindow instance
"""
QWidget.__init__(self, parent)
self.parent = parent
self.on_update = on_update
self.label = QLabel(label)
self.qt_time = QTime.fromString(initial_time)
self.time_edit = QTimeEdit(self.qt_time)
self.time_edit.timeChanged.connect(self.update)
self.grid = QGridLayout()
self.fill_layout()
self.setLayout(self.grid)
示例4: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QWidget [as 別名]
# 或者: from PyQt5.QtWidgets.QWidget import __init__ [as 別名]
def __init__(self, parent, color=None, on_color_change=None, name='Color', verify_colors=False):
"""
Args:
parent: a parent Qt instance
color: the color name or hexadecimal code (in form of a string)
on_color_change: a function or method taking old color and a new one
verify_colors: should the parent be asked if the color is acceptable?
to verify a color parent.is_acceptable(color) will be invoked
"""
QPushButton.__init__(self, color, parent)
self.verify_colors = verify_colors
self.parent = parent
self.color = color
self.name = name
self.callback = on_color_change
if color:
self.set_color(color)
else:
self.setText(_('(Not specified)'))
self.clicked.connect(self.pick_color)
示例5: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QWidget [as 別名]
# 或者: from PyQt5.QtWidgets.QWidget import __init__ [as 別名]
def __init__(self, client, *args, **kwargs):
self.client = client
QWidget.__init__(self, *args, **kwargs)
self.setLayout(QVBoxLayout())
self.layout().setContentsMargins(0, 0, 0, 0)
self.tab_widg = QTabWidget()
self.active_widg = ActiveMacroWidget(client)
self.active_ind = self.tab_widg.count()
self.tab_widg.addTab(self.active_widg, "Active")
self.int_widg = IntMacroWidget(client)
self.int_ind = self.tab_widg.count()
self.tab_widg.addTab(self.int_widg, "Intercepting")
self.warning_widg = QLabel("<h1>Warning! Macros may cause instability</h1><p>Macros load and run python files into the Guppy process. If you're not careful when you write them you may cause Guppy to crash. If an active macro ends up in an infinite loop you may need to force kill the application when you quit.</p><p><b>PROCEED WITH CAUTION</b></p>")
self.warning_widg.setWordWrap(True)
self.tab_widg.addTab(self.warning_widg, "Warning")
self.layout().addWidget(self.tab_widg)
示例6: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QWidget [as 別名]
# 或者: from PyQt5.QtWidgets.QWidget import __init__ [as 別名]
def __init__(self, enable_pretty=True):
QWidget.__init__(self)
layout = QVBoxLayout()
self.enable_pretty = enable_pretty
self.setLayout(layout)
self.layout().setSpacing(0)
self.layout().setContentsMargins(0, 0, 0, 0)
self.lexer = TextLexer()
self.textedit = QTextEdit()
self.textedit.setAcceptRichText(False)
doc = self.textedit.document()
font = doc.defaultFont()
font.setFamily("Courier New")
font.setPointSize(10)
doc.setDefaultFont(font)
doc.addResource(QTextDocument.ImageResource,
QUrl(self.byte_url),
HextEditor.byte_image)
self.textedit.focusInEvent = self.focus_in_event
self.textedit.focusOutEvent = self.focus_left_event
self.data = b''
self.pretty_mode = False
self.layout().addWidget(self.textedit)
示例7: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QWidget [as 別名]
# 或者: from PyQt5.QtWidgets.QWidget import __init__ [as 別名]
def __init__(self, *args, **kwargs):
QWidget.__init__(self, *args, **kwargs)
self.request = None
self.setLayout(QVBoxLayout())
self.layout().setSpacing(0)
self.layout().setContentsMargins(0, 0, 0, 0)
self.infotable = QTableWidget()
self.infotable.setColumnCount(2)
self.infotable.verticalHeader().hide()
self.infotable.horizontalHeader().hide()
self.infotable.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
self.infotable.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
self.infotable.horizontalHeader().setStretchLastSection(True)
self.layout().addWidget(self.infotable)
示例8: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QWidget [as 別名]
# 或者: from PyQt5.QtWidgets.QWidget import __init__ [as 別名]
def __init__(self, *args, **kwargs):
QWidget.__init__(self)
layout = QVBoxLayout()
tool_layout = QHBoxLayout()
self.editor = ComboEditor(pretty_tab=False, enable_pretty=False)
self.encode_entry = QComboBox()
encode_button = QPushButton("Go!")
encode_button.clicked.connect(self.encode)
for k, v in self.decoders.items():
self.encode_entry.addItem(v[0], k)
layout.addWidget(self.editor)
tool_layout.addWidget(self.encode_entry)
tool_layout.addWidget(encode_button)
tool_layout.addStretch()
layout.addLayout(tool_layout)
self.setLayout(layout)
self.layout().setContentsMargins(0, 0, 0, 0)
示例9: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QWidget [as 別名]
# 或者: from PyQt5.QtWidgets.QWidget import __init__ [as 別名]
def __init__(self, *args, **kwargs):
QWidget.__init__(self, *args, **kwargs)
self.str2_shown = False
self.str1 = StringCmpWidget()
self.str2 = StringCmpWidget()
self.str1.returnPressed.connect(self.returnPressed)
self.str2.returnPressed.connect(self.returnPressed)
self.toggle_button = QToolButton()
self.toggle_button.setText("+")
self.toggle_button.clicked.connect(self._show_hide_str2)
layout = QHBoxLayout()
layout.addWidget(self.str1)
layout.addWidget(self.str2)
layout.addWidget(self.toggle_button)
self.str2.setVisible(self.str2_shown)
self.setLayout(layout)
self.layout().setContentsMargins(0, 0, 0, 0)
示例10: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QWidget [as 別名]
# 或者: from PyQt5.QtWidgets.QWidget import __init__ [as 別名]
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.lists = None
self.list_index = 0
示例11: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QWidget [as 別名]
# 或者: from PyQt5.QtWidgets.QWidget import __init__ [as 別名]
def __init__(self, parent=None):
"""Initialize the widget
"""
QWidget.__init__(self, parent)
# Init the main widget
self.u = gui_option.unit
self.setTitle(self.tr("Output"))
self.setMinimumSize(QSize(300, 0))
self.setObjectName("g_output")
self.layout = QVBoxLayout(self)
self.layout.setObjectName("layout")
# The widget is composed of several QLabel in a vertical layout
self.out_Rint = QLabel(self)
self.out_Rint.setObjectName("out_Rint")
self.layout.addWidget(self.out_Rint)
self.out_Rext = QLabel(self)
self.out_Rext.setObjectName("out_Rext")
self.layout.addWidget(self.out_Rext)
self.out_lam_surface = QLabel(self)
self.out_lam_surface.setObjectName("out_lam_surface")
self.layout.addWidget(self.out_lam_surface)
self.out_lam_vent_surface = QLabel(self)
self.out_lam_vent_surface.setObjectName("out_lam_vent_surface")
self.layout.addWidget(self.out_lam_vent_surface)
self.out_vent_surf = QLabel(self)
self.out_vent_surf.setObjectName("out_vent_surf")
self.layout.addWidget(self.out_vent_surf)
# self.layout.addWidget(self)
示例12: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QWidget [as 別名]
# 或者: from PyQt5.QtWidgets.QWidget import __init__ [as 別名]
def __init__(self, lam, index):
"""Initialize the widget according the current lamination
Parameters
----------
self : WVent
A WVent widget
lam : Lamination
current lamination to edit
index : int
Index of the ventilation in the list to update
"""
# Build the interface according to the .ui file
QWidget.__init__(self)
self.setupUi(self)
self.obj = lam
self.index = index
# Avoid erase all the parameters when navigating though the vents
self.previous_vent = dict()
for vent_type in INIT_INDEX:
self.previous_vent[vent_type] = None
self.c_vent_type.setCurrentIndex(INIT_INDEX.index(type(lam.axial_vent[index])))
# Regenerate the pages with the new values
self.w_vent.setParent(None)
self.w_vent = PAGE_INDEX[self.c_vent_type.currentIndex()](
lam=lam, vent=lam.axial_vent[index]
)
# Refresh the GUI
self.main_layout.removeWidget(self.w_vent)
self.main_layout.insertWidget(1, self.w_vent)
# Connect the slot/signel
self.c_vent_type.currentIndexChanged.connect(self.set_vent_type)
示例13: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QWidget [as 別名]
# 或者: from PyQt5.QtWidgets.QWidget import __init__ [as 別名]
def __init__(self, lamination=None):
"""Initialize the GUI according to current lamination
Parameters
----------
self : PWSlot12
A PWSlot12 widget
lamination : Lamination
current lamination to edit
"""
# Build the interface according to the .ui file
QWidget.__init__(self)
self.setupUi(self)
self.lamination = lamination
self.slot = lamination.slot
# Set FloatEdit unit
self.lf_R1.unit = "m"
self.lf_R2.unit = "m"
self.lf_H0.unit = "m"
self.lf_H1.unit = "m"
# Set unit name (m ou mm)
wid_list = [self.unit_R1, self.unit_R2, self.unit_H0, self.unit_H1]
for wid in wid_list:
wid.setText(gui_option.unit.get_m_name())
# Fill the fields with the machine values (if they're filled)
self.lf_R1.setValue(self.slot.R1)
self.lf_R2.setValue(self.slot.R2)
self.lf_H0.setValue(self.slot.H0)
self.lf_H1.setValue(self.slot.H1)
# Display the main output of the slot (surface, height...)
self.w_out.comp_output()
# Connect the signal
self.lf_R1.editingFinished.connect(self.set_R1)
self.lf_R2.editingFinished.connect(self.set_R2)
self.lf_H0.editingFinished.connect(self.set_H0)
self.lf_H1.editingFinished.connect(self.set_H1)
示例14: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QWidget [as 別名]
# 或者: from PyQt5.QtWidgets.QWidget import __init__ [as 別名]
def __init__(self, parent=None):
"""Initialize the widget
"""
QWidget.__init__(self, parent)
# Set main widget
self.setTitle(self.tr("Output"))
self.setMinimumSize(QSize(200, 0))
self.setObjectName("g_output")
self.layout = QVBoxLayout(self)
self.layout.setObjectName("layout")
# The widget is composed of several QLabel in a vertical layout
self.out_Wlam = QLabel(self)
self.out_Wlam.setObjectName("out_Wlam")
self.layout.addWidget(self.out_Wlam)
self.out_slot_height = QLabel(self)
self.out_slot_height.setObjectName("out_slot_height")
self.layout.addWidget(self.out_slot_height)
self.out_yoke_height = QLabel(self)
self.out_yoke_height.setObjectName("out_yoke_height")
self.layout.addWidget(self.out_yoke_height)
self.out_wind_surface = QLabel(self)
self.out_wind_surface.setObjectName("out_wind_surface")
self.layout.addWidget(self.out_wind_surface)
self.out_tot_surface = QLabel(self)
self.out_tot_surface.setObjectName("out_tot_surface")
self.layout.addWidget(self.out_tot_surface)
self.out_op_angle = QLabel(self)
self.out_op_angle.setObjectName("out_op_angle")
self.layout.addWidget(self.out_op_angle)
# self.layout.addWidget(self)
示例15: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QWidget [as 別名]
# 或者: from PyQt5.QtWidgets.QWidget import __init__ [as 別名]
def __init__(self, machine=None, dmatlib=None, machine_path=""):
"""Initialize the GUI according to machine type
Parameters
----------
self : DMachineSetup
a DMachineSetup object
"""
# Build the interface according to the .ui file
QWidget.__init__(self)
self.setupUi(self)
self.is_save_needed = False
self.dmatlib = dmatlib
self.matlib = dmatlib.matlib
self.last_index = 0 # Index of the last step available
# Saving arguments
self.machine = machine
if machine_path == "":
self.machine_path = join(DATA_DIR, "Machine")
else:
self.machine_path = machine_path
# Initialize the machine if needed
if machine is None:
self.machine = type(mach_list[0]["init_machine"])(
init_dict=mach_list[0]["init_machine"].as_dict()
)
self.update_nav()
self.set_nav(self.last_index)
# Connect save/load button
self.nav_step.currentRowChanged.connect(self.set_nav)
self.b_save.clicked.connect(self.s_save)
self.b_load.clicked.connect(self.s_load)
self.dmatlib.saveNeeded.connect(self.save_needed)