def __init__(self, *args):
QtWidgets.QFrame.__init__(self, *args)
self.setFrameStyle(QtWidgets.QFrame.StyledPanel | QtWidgets.QFrame.Sunken)
self.edit = self.PlainTextEdit()
self.number_bar = self.NumberBar(self.edit)
hbox = QtWidgets.QHBoxLayout(self)
hbox.setSpacing(0)
hbox.setContentsMargins(0,0,0,0) # setMargin
hbox.addWidget(self.number_bar)
hbox.addWidget(self.edit)
self.edit.blockCountChanged.connect(self.number_bar.adjustWidth)
self.edit.updateRequest.connect(self.number_bar.updateContents)
python类QFrame()的实例源码
LNTextEdit_v3.2.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 19
收藏 0
点赞 0
评论 0
def __init__(self, *args):
QtGui.QFrame.__init__(self, *args)
self.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Sunken)
self.edit = self.PlainTextEdit()
self.number_bar = self.NumberBar(self.edit)
hbox = QtGui.QHBoxLayout(self)
hbox.setSpacing(0)
hbox.setContentsMargins(0,0,0,0) # setMargin
hbox.addWidget(self.number_bar)
hbox.addWidget(self.edit)
self.edit.blockCountChanged.connect(self.number_bar.adjustWidth)
self.edit.updateRequest.connect(self.number_bar.updateContents)
def __init__(self):
super(HSeparator, self).__init__()
self.setFrameShape(QtGui.QFrame.HLine)
self.setFrameShadow(QtGui.QFrame.Sunken)
#creation de notre fenetre avec pyside
def setupUi(self, type_widget):
type_widget.setObjectName("type_widget")
type_widget.resize(248, 78)
self.horizontalLayout_2 = QtGui.QHBoxLayout(type_widget)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.type_icon = QtGui.QLabel(type_widget)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.type_icon.sizePolicy().hasHeightForWidth())
self.type_icon.setSizePolicy(sizePolicy)
self.type_icon.setObjectName("type_icon")
self.horizontalLayout_2.addWidget(self.type_icon)
spacerItem = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem)
self.line = QtGui.QFrame(type_widget)
self.line.setFrameShape(QtGui.QFrame.VLine)
self.line.setFrameShadow(QtGui.QFrame.Sunken)
self.line.setObjectName("line")
self.horizontalLayout_2.addWidget(self.line)
spacerItem1 = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem1)
self.type_label = QtGui.QLabel(type_widget)
font = QtGui.QFont()
font.setFamily("Cantarell")
font.setPointSize(10)
font.setWeight(75)
font.setBold(True)
self.type_label.setFont(font)
self.type_label.setObjectName("type_label")
self.horizontalLayout_2.addWidget(self.type_label)
self.retranslateUi(type_widget)
QtCore.QMetaObject.connectSlotsByName(type_widget)
def __init__(self, parent=None):
QtGui.QFrame.__init__(self, parent)
#
self.setFrameShape(QtGui.QFrame.HLine)
self.setFrameShadow(QtGui.QFrame.Sunken)
self.setLineWidth(1)
def __init__(self, parent=None):
QtGui.QFrame.__init__(self, parent)
#
self.setFrameShape(QtGui.QFrame.HLine)
self.setFrameShadow(QtGui.QFrame.Sunken)
self.setLineWidth(1)
def __init__(self, parent=None):
QtGui.QFrame.__init__(self, parent)
#
self.setFrameShape(QtGui.QFrame.HLine)
self.setFrameShadow(QtGui.QFrame.Sunken)
self.setLineWidth(1)
def initUI(self):
self._layout = QtGui.QGridLayout(None)
self.setLayout(self._layout)
self._layout.setContentsMargins(0,5,0,5)
self._layout.setSpacing(0)
self._topBar = QtGui.QFrame()
self._topBarLayout = QtGui.QHBoxLayout(self._topBar)
self._refreshProgression = QtGui.QProgressBar()
self._refreshProgression.setMinimum(0)
self._refreshProgression.setMaximum(100)
self._refreshProgression.setValue(10)
self._refreshButton = QtGui.QPushButton("Refresh")
self._filterLabel = QtGui.QLabel("Filter :")
self._filterField = QtGui.QLineEdit()
self._topBarLayout.addWidget(self._refreshProgression)
self._topBarLayout.addWidget(self._refreshButton)
self._topBarLayout.addWidget(self._filterLabel)
self._topBarLayout.addWidget(self._filterField)
self.generateJobList()
self._layout.addWidget(self._topBar)
self._layout.addWidget(self._jobList)
self._autoRefresh = JobListAutoRefresh(self,self._refreshProgression)
#autoRefresh.run()
self._refreshButton.clicked.connect(self.startRefresh)
def initUI(self):
l = QtGui.QVBoxLayout(self)
l.setContentsMargins(0,0,0,0)
w = QtGui.QFrame(self)
l.addWidget(w)
self._layout = QtGui.QVBoxLayout()
#self.setLayout(self._layout)
w.setLayout(self._layout)
self._layout.setContentsMargins(0,0,0,0)
icnPath = "/Users/draknova/Documents/workspace/sPipe/bin/images/icons/"
icn1 = QtGui.QIcon(QtGui.QPixmap("%s/home.png"%(icnPath)))
icn2 = QtGui.QIcon(QtGui.QPixmap("%s/server.png"%(icnPath)))
icn3 = QtGui.QIcon(QtGui.QPixmap("%s/database.png"%(icnPath)))
icn4 = QtGui.QIcon(QtGui.QPixmap("%s/network.png"%(icnPath)))
icn5 = QtGui.QIcon(QtGui.QPixmap("%s/settings.png"%(icnPath)))
b1 = QtGui.QPushButton(icn1,"")
b2 = QtGui.QPushButton(icn2,"")
b3 = QtGui.QPushButton(icn3,"")
b4 = QtGui.QPushButton(icn4,"")
b5 = QtGui.QPushButton(icn5,"")
self._layout.addWidget(b1)
self._layout.addWidget(b2)
self._layout.addWidget(b3)
self._layout.addWidget(b4)
self._layout.addWidget(b5)
self._layout.addStretch()
def __init__(self, *args):
QtWidgets.QPlainTextEdit.__init__(self, *args)
self.setFrameStyle(QtWidgets.QFrame.NoFrame)
self.zoomWheelEnabled = 0
self.highlight()
#self.setLineWrapMode(QtWidgets.QPlainTextEdit.NoWrap)
self.cursorPositionChanged.connect(self.highlight)
def setReadOnlyStyle(self, state):
if state == 1:
mainWindowBgColor = QtWidgets.QPalette().color(QtWidgets.QPalette.Window)
self.setStyleSheet('QPlainTextEdit[readOnly="true"] { background-color: %s;} QFrame {border: 0px}' % mainWindowBgColor.name() )
self.setHighlight(0)
else:
self.setStyleSheet('')
self.setHighlight(1)
LNTextEdit_v3.2.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 24
收藏 0
点赞 0
评论 0
def __init__(self, *args):
QtGui.QPlainTextEdit.__init__(self, *args)
self.setFrameStyle(QtGui.QFrame.NoFrame)
self.zoomWheelEnabled = 0
self.highlight()
#self.setLineWrapMode(QtGui.QPlainTextEdit.NoWrap)
self.cursorPositionChanged.connect(self.highlight)
def chat_add_line_to_message(self, add_window, v_layout):
# H
h_layout = QtGui.QHBoxLayout()
line_frame = QtGui.QFrame(parent = add_window.new_topics_frame)
# button
button = QtGui.QPushButton('img', parent = line_frame)
button.setFixedSize(100, 100)
button.img_path = False
h_layout.addWidget(button)
# -- button connect
button.clicked.connect(partial(self.chat_image_view_ui, button))
button.setContextMenuPolicy( QtCore.Qt.ActionsContextMenu )
addgrup_action = QtGui.QAction( 'Inser Image From Clipboard', add_window)
addgrup_action.triggered.connect(partial(self.chat_add_img_to_line, button))
button.addAction( addgrup_action )
# text field
text_field = QtGui.QTextEdit(parent = line_frame)
text_field.setMaximumHeight(100)
h_layout.addWidget(text_field)
line_frame.setLayout(h_layout)
v_layout.addWidget(line_frame)
# ****** append line data
# -- get num
numbers = []
for key in add_window.line_data.keys():
numbers.append(int(key))
num = max(numbers) + 1
add_window.line_data[str(num)] = (button, text_field)
def tm_make_preview_ui(self):
self.makePreviewDialog = QtGui.QDialog(self)
self.makePreviewDialog.setModal(True)
#self.makePreviewDialog.resize(300, 300)
self.makePreviewDialog.setWindowTitle(('Make Preview: /// ' + self.current_task['asset']))
# add widgets
v_layout = QtGui.QVBoxLayout()
# -- image Label
self.makePreviewDialog.imageLabel = QtGui.QLabel()
self.makePreviewDialog.imageLabel.setFixedSize(300,300)
v_layout.addWidget(self.makePreviewDialog.imageLabel)
# -- button
h__layout = QtGui.QHBoxLayout()
button_frame = QtGui.QFrame(parent = self.makePreviewDialog)
cansel_button = QtGui.QPushButton('Cansel', parent = button_frame)
h__layout.addWidget(cansel_button)
paste_button = QtGui.QPushButton('Paste', parent = button_frame)
h__layout.addWidget(paste_button)
save_button = QtGui.QPushButton('Save', parent = button_frame)
h__layout.addWidget(save_button)
button_frame.setLayout(h__layout)
v_layout.addWidget(button_frame)
self.makePreviewDialog.setLayout(v_layout)
# connect buttons
cansel_button.clicked.connect(partial(self.close_window, self.makePreviewDialog))
paste_button.clicked.connect(partial(self.tm_paste_image_from_clipboard, self.makePreviewDialog.imageLabel))
save_button.clicked.connect(partial(self.tm_save_preview_image_action, self.makePreviewDialog))
# -- load img to label
img_path = os.path.join(self.db_chat.preview_img_path, (self.current_task['asset'] + '.png'))
if not os.path.exists(img_path):
self.makePreviewDialog.imageLabel.setText('No Image')
else:
image = QtGui.QImage(img_path)
self.makePreviewDialog.imageLabel.setPixmap(QtGui.QPixmap.fromImage(image))
self.makePreviewDialog.show()
def chat_add_line_to_message(self, add_window, v_layout):
# H
h_layout = QtGui.QHBoxLayout()
line_frame = QtGui.QFrame(parent = add_window.new_topics_frame)
# button
button = QtGui.QPushButton('img', parent = line_frame)
button.setFixedSize(100, 100)
button.img_path = False
h_layout.addWidget(button)
# -- button connect
button.clicked.connect(partial(self.chat_image_view_ui, button))
button.setContextMenuPolicy( QtCore.Qt.ActionsContextMenu )
addgrup_action = QtGui.QAction( 'Inser Image From Clipboard', add_window)
addgrup_action.triggered.connect(partial(self.chat_add_img_to_line, button))
button.addAction( addgrup_action )
# text field
text_field = QtGui.QTextEdit(parent = line_frame)
text_field.setMaximumHeight(100)
h_layout.addWidget(text_field)
line_frame.setLayout(h_layout)
v_layout.addWidget(line_frame)
# ****** append line data
# -- get num
numbers = []
for key in add_window.line_data.keys():
numbers.append(int(key))
num = max(numbers) + 1
add_window.line_data[str(num)] = (button, text_field)
def setupUi(self):
"""Bruh"""
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.setGeometry(50, 50, 850, 425)
self.setWindowTitle("ZeZe's TWTools - Coord Extractor")
self.setWindowIcon(QtGui.QIcon(resource_path("images/icon.png")))
"""Background color"""
self.backgroundPalette = QtGui.QPalette()
self.backgroundColor = QtGui.QColor(217, 204, 170)
self.backgroundPalette.setColor(QtGui.QPalette.Background, self.backgroundColor)
self.setPalette(self.backgroundPalette)
"""Main layout & return to main menu button"""
self.verticalLayout = QtGui.QVBoxLayout(self)
self.buttonLayout = QtGui.QHBoxLayout(self)
self.verticalLayout.addLayout(self.buttonLayout)
self.returnButton = QtGui.QPushButton(" Return to the Main Menu ", self)
self.returnButton.clicked.connect(self.return_function)
self.buttonLayout.addWidget(self.returnButton)
self.buttonSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.buttonLayout.addItem(self.buttonSpacer)
"""Line Spacer and line"""
self.lineSpacer = QtGui.QSpacerItem(40, 5, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.verticalLayout.addItem(self.lineSpacer)
self.line = QtGui.QFrame(self)
self.line.setFrameShape(QtGui.QFrame.HLine)
self.line.setFrameShadow(QtGui.QFrame.Sunken)
self.verticalLayout.addWidget(self.line)
"""Text input label and edit"""
self.Spacer = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.verticalLayout.addItem(self.Spacer)
self.inputLabel = QtGui.QLabel("Input text with coordinates here:")
self.verticalLayout.addWidget(self.inputLabel)
self.plainTextEdit = QtGui.QPlainTextEdit(self)
self.verticalLayout.addWidget(self.plainTextEdit)
"""Coordinates output label and edit"""
self.Spacer1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.verticalLayout.addItem(self.Spacer1)
self.outputLabel = QtGui.QLabel("Output coordinates magically appear here:")
self.verticalLayout.addWidget(self.outputLabel)
self.plainTextEdit_2 = QtGui.QPlainTextEdit(self)
self.verticalLayout.addWidget(self.plainTextEdit_2)
"""Extract coordinates button"""
self.horizontalLayout = QtGui.QHBoxLayout()
self.verticalLayout.addLayout(self.horizontalLayout)
self.Spacer2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horizontalLayout.addItem(self.Spacer2)
self.extractButton = QtGui.QPushButton(" Extract Coordinates ", self)
self.extractButton.clicked.connect(self.extract_function)
self.horizontalLayout.addWidget(self.extractButton)
def __init__(self,parcelation_filename, template_filename,correlationTable,selectedColor,colorTable,SliceX,SliceY,SliceZ):
super(VolumneRendererWindow,self).__init__()
self.correlationTable = correlationTable
self.nRegions = len(self.correlationTable.header)
self.selectedColor = selectedColor
self.widget = None
self.SliceX = SliceX
self.SliceY = SliceY
self.SliceZ = SliceZ
self.colorTable = colorTable
self.region_data = nib.load(parcelation_filename).get_data().astype(np.uint32)
self.Centroid = dict()
self.regionPlotId = -1
self.centroidPlotId = -1
self.activePlotId = -1
self.activePlotId = self.regionPlotId
self.parcelation_filename = parcelation_filename
self.template_filename = template_filename
self.setCentreFilename()
self.frame = QtGui.QFrame()
self.BoxLayoutView = QtGui.QVBoxLayout()
self.BoxLayoutView.setContentsMargins(0, 0, 0, 0)
self.setLayout(self.BoxLayoutView)
self.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
self.setDataset()
self.setFlags()
self.RenderData()
# Create source
source = vtk.vtkSphereSource()
source.SetCenter(0, 0, 0)
source.SetRadius(5.0)
self.FinalRenderView()
self.show()
def __init__(self,parcelation_filename, template_filename,correlationTable,selectedColor,colorTable,SliceX,SliceY,SliceZ):
super(ParcelationPlotWindow,self).__init__()
self.correlationTable = correlationTable
self.nRegions = len(self.correlationTable.data)
self.selectedColor = selectedColor
self.widget = None
self.SliceX = SliceX
self.SliceY = SliceY
self.SliceZ = SliceZ
self.colorTable = colorTable
self.region_data = nib.load(parcelation_filename).get_data().astype(np.uint32)
self.Centroid = dict()
self.regionPlotId = -1
self.centroidPlotId = -1
self.activePlotId = -1
self.activePlotId = self.regionPlotId
self.parcelation_filename = parcelation_filename
self.template_filename = template_filename
self.setCentreFilename()
self.frame = QtGui.QFrame()
self.BoxLayoutView = QtGui.QVBoxLayout()
self.BoxLayoutView.setContentsMargins(0, 0, 0, 0)
self.setLayout(self.BoxLayoutView)
self.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
self.setDataset()
self.setFlags()
self.RenderData()
# Create source
source = vtk.vtkSphereSource()
source.SetCenter(0, 0, 0)
source.SetRadius(5.0)
self.FinalRenderView()
self.show()
self.renderInteractor.Initialize()
def __init__(self, sql, parent=None):
QtGui.QDialog.__init__(self, parent)
self.setWindowTitle(u'Import database')
self.sql = sql
# file
self.filePath = QtGui.QLineEdit('')
self.filePath.setReadOnly(True)
filePathButton = QtGui.QPushButton('...')
self.connect(filePathButton, QtCore.SIGNAL("clicked()"), self.chooseFile)
filePathFrame = QtGui.QFrame()
filePathFrame.setObjectName('lay_path_widget')
filePathFrame.setStyleSheet('''#lay_path_widget {background-color:#fff; border:1px solid rgb(199, 199, 199); padding: 5px;}''')
filePathLayout = QtGui.QHBoxLayout(filePathFrame)
filePathLayout.addWidget(QtGui.QLabel(u'File:\t'))
filePathLayout.addWidget(self.filePath)
filePathLayout.addWidget(filePathButton)
filePathLayout.setContentsMargins(0, 0, 0, 0)
# tabs
self.tabs = QtGui.QTabWidget()
self.tabs.setTabPosition(QtGui.QTabWidget.West)
self.tabs.setObjectName('tabs_widget')
self.tabs.addTab(self.tabCategories(), u'Categories')
self.tabs.addTab(self.tabModels(), u'Models')
self.tabs.setTabEnabled(1, False)
self.connect(self.tabs, QtCore.SIGNAL("currentChanged (int)"), self.activeModelsTab)
# buttons
buttons = QtGui.QDialogButtonBox()
buttons.addButton("Cancel", QtGui.QDialogButtonBox.RejectRole)
buttons.addButton("Import", QtGui.QDialogButtonBox.AcceptRole)
self.connect(buttons, QtCore.SIGNAL("accepted()"), self, QtCore.SLOT("accept()"))
self.connect(buttons, QtCore.SIGNAL("rejected()"), self, QtCore.SLOT("reject()"))
buttonsFrame = QtGui.QFrame()
buttonsFrame.setObjectName('lay_path_widget')
buttonsFrame.setStyleSheet('''#lay_path_widget {background-color:#fff; border:1px solid rgb(199, 199, 199); padding: 5px;}''')
buttonsLayout = QtGui.QHBoxLayout(buttonsFrame)
buttonsLayout.addWidget(buttons)
buttonsLayout.setContentsMargins(0, 0, 0, 0)
# main layout
lay = QtGui.QGridLayout(self)
lay.addWidget(filePathFrame, 0, 0, 1, 1)
lay.addWidget(self.tabs, 1, 0, 1, 1)
lay.addWidget(buttonsFrame, 2, 0, 1, 1)
lay.setRowStretch(1, 10)
lay.setContentsMargins(5, 5, 5, 5)
def chat_new_topic_ui(self, window):
# make widjet
ui_path = G.MW.chat_add_topic_path
# widget
loader = QtUiTools.QUiLoader()
file = QtCore.QFile(ui_path)
#file.open(QtCore.QFile.ReadOnly)
add_window = G.MW.chatAddTopic = loader.load(file, G.MW)
file.close()
# set modal window
add_window.setWindowModality(QtCore.Qt.WindowModal)
add_window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
# ****** add first line
# H
h_layout = QtGui.QHBoxLayout()
line_frame = QtGui.QFrame(parent = add_window.new_topics_frame)
# button
button = QtGui.QPushButton('img', parent = line_frame)
button.setFixedSize(100, 100)
button.img_path = False
h_layout.addWidget(button)
# -- button connect
button.clicked.connect(partial(self.chat_image_view_ui, button))
button.setContextMenuPolicy( QtCore.Qt.ActionsContextMenu )
addgrup_action = QtGui.QAction( 'Inser Image From Clipboard', add_window)
addgrup_action.triggered.connect(partial(self.chat_add_img_to_line, button))
button.addAction( addgrup_action )
# text field
text_field = QtGui.QTextEdit(parent = line_frame)
#text_field = QtGui.QTextBrowser(parent = line_frame)
text_field.setMaximumHeight(100)
h_layout.addWidget(text_field)
line_frame.setLayout(h_layout)
# V
v_layout = QtGui.QVBoxLayout()
v_layout.addWidget(line_frame)
add_window.new_topics_frame.setLayout(v_layout)
# ****** append line data
add_window.line_data = {}
add_window.line_data['1'] = (button, text_field)
# connect button
add_window.cansel_button.clicked.connect(partial(G.MW.close_window, add_window))
add_window.add_line_button.clicked.connect(partial(self.chat_add_line_to_message, add_window, v_layout))
add_window.send_message_button.clicked.connect(partial(self.chat_new_topic_action, add_window, G.MW.chat_status))
add_window.show()
def chat_new_topic_ui(self, window):
# make widjet
ui_path = G.MW.chat_add_topic_path
# widget
loader = QtUiTools.QUiLoader()
file = QtCore.QFile(ui_path)
#file.open(QtCore.QFile.ReadOnly)
add_window = G.MW.chatAddTopic = loader.load(file, G.MW)
file.close()
# set modal window
add_window.setWindowModality(QtCore.Qt.WindowModal)
add_window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
# ****** add first line
# H
h_layout = QtGui.QHBoxLayout()
line_frame = QtGui.QFrame(parent = add_window.new_topics_frame)
# button
button = QtGui.QPushButton('img', parent = line_frame)
button.setFixedSize(100, 100)
button.img_path = False
h_layout.addWidget(button)
# -- button connect
button.clicked.connect(partial(self.chat_image_view_ui, button))
button.setContextMenuPolicy( QtCore.Qt.ActionsContextMenu )
addgrup_action = QtGui.QAction( 'Inser Image From Clipboard', add_window)
addgrup_action.triggered.connect(partial(self.chat_add_img_to_line, button))
button.addAction( addgrup_action )
# text field
text_field = QtGui.QTextEdit(parent = line_frame)
#text_field = QtGui.QTextBrowser(parent = line_frame)
text_field.setMaximumHeight(100)
h_layout.addWidget(text_field)
line_frame.setLayout(h_layout)
# V
v_layout = QtGui.QVBoxLayout()
v_layout.addWidget(line_frame)
add_window.new_topics_frame.setLayout(v_layout)
# ****** append line data
add_window.line_data = {}
add_window.line_data['1'] = (button, text_field)
# connect button
add_window.cansel_button.clicked.connect(partial(G.MW.close_window, add_window))
add_window.add_line_button.clicked.connect(partial(self.chat_add_line_to_message, add_window, v_layout))
add_window.send_message_button.clicked.connect(partial(self.chat_new_topic_action, add_window, G.MW.chat_status))
add_window.show()