def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent)
self.setWindowTitle(u'Add new category')
#
self.categoryName = QtGui.QLineEdit('')
self.categoryName.setStyleSheet('background-color:#FFF;')
self.categoryDescription = QtGui.QTextEdit('')
# buttons
buttons = QtGui.QDialogButtonBox()
buttons.setOrientation(QtCore.Qt.Vertical)
buttons.addButton("Cancel", QtGui.QDialogButtonBox.RejectRole)
buttons.addButton("Add", QtGui.QDialogButtonBox.AcceptRole)
self.connect(buttons, QtCore.SIGNAL("accepted()"), self, QtCore.SLOT("accept()"))
self.connect(buttons, QtCore.SIGNAL("rejected()"), self, QtCore.SLOT("reject()"))
#
lay = QtGui.QGridLayout(self)
lay.addWidget(QtGui.QLabel(u'Name'), 0, 0, 1, 1)
lay.addWidget(self.categoryName, 0, 1, 1, 1)
lay.addWidget(QtGui.QLabel(u'Desctiption'), 1, 0, 1, 1, QtCore.Qt.AlignTop)
lay.addWidget(self.categoryDescription, 1, 1, 1, 1)
lay.addWidget(buttons, 0, 2, 2, 1, QtCore.Qt.AlignCenter)
lay.setRowStretch(1, 10)
python类QTextEdit()的实例源码
def initUI(self):
self.setMinimumSize(50,100)
self.menu = QtGui.QMenuBar()
self.menu.addMenu("Test")
self.layout = QtGui.QBoxLayout(QtGui.QBoxLayout.TopToBottom,None)
self.setLayout(self.layout)
self.layout.setContentsMargins(0,0,0,0)
self.console = QtGui.QTextEdit()
self.console.setReadOnly(True)
self.layout.addWidget(self.menu)
self.layout.addWidget(self.console)
def __init__(self,widgets=None):
super(QPanel,self).__init__()
self.setAcceptDrops(True)
self._tabBar = None
self._widgets = list()
self.initUI()
# Add widget a creation
if widgets != None:
for i,w in enumerate(widgets):
#self.addPanel(w, ("Tab %i"%(i)), i)
pass
else:
i = panel.NodePanel.NodePanel()
j = QtGui.QTextEdit("Tab 2")
#self.addPanel(i, "Node Editor", 0)
#self.addPanel(j, "Tab", 1)
pass
# Set to first tab
#self.setCurrentTab(0)
pass
def __init__(self, *args,**kwargs):
super(MainWidget, self).__init__(*args,**kwargs)
self.setLayout(QtGui.QHBoxLayout())
self.bkg_wdgt = QtGui.QWidget()
self.layout().addWidget(self.bkg_wdgt)
self.bkg_wdgt.setLayout(QtGui.QHBoxLayout())
self.btn = QtGui.QPushButton("hallo")
self.textarea = QtGui.QTextEdit()
self.bkg_wdgt.layout().addWidget(self.btn)
self.bkg_wdgt.layout().addWidget(self.textarea)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.btn.clicked.connect(self.on_btn_clicked)
# self.parent_hwnd = None
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(529, 329)
self.selInfoWidget = QtGui.QWidget(Form)
self.selInfoWidget.setGeometry(QtCore.QRect(260, 10, 264, 222))
self.selInfoWidget.setObjectName("selInfoWidget")
self.gridLayout = QtGui.QGridLayout(self.selInfoWidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.selDescLabel = QtGui.QLabel(self.selInfoWidget)
self.selDescLabel.setText("")
self.selDescLabel.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
self.selDescLabel.setWordWrap(True)
self.selDescLabel.setObjectName("selDescLabel")
self.gridLayout.addWidget(self.selDescLabel, 0, 0, 1, 1)
self.selNameLabel = QtGui.QLabel(self.selInfoWidget)
font = QtGui.QFont()
font.setWeight(75)
font.setBold(True)
self.selNameLabel.setFont(font)
self.selNameLabel.setText("")
self.selNameLabel.setObjectName("selNameLabel")
self.gridLayout.addWidget(self.selNameLabel, 0, 1, 1, 1)
self.selectedTree = DataTreeWidget(self.selInfoWidget)
self.selectedTree.setObjectName("selectedTree")
self.selectedTree.headerItem().setText(0, "1")
self.gridLayout.addWidget(self.selectedTree, 1, 0, 1, 2)
self.hoverText = QtGui.QTextEdit(Form)
self.hoverText.setGeometry(QtCore.QRect(0, 240, 521, 81))
self.hoverText.setObjectName("hoverText")
self.view = FlowchartGraphicsView(Form)
self.view.setGeometry(QtCore.QRect(0, 0, 256, 192))
self.view.setObjectName("view")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(529, 329)
self.selInfoWidget = QtGui.QWidget(Form)
self.selInfoWidget.setGeometry(QtCore.QRect(260, 10, 264, 222))
self.selInfoWidget.setObjectName("selInfoWidget")
self.gridLayout = QtGui.QGridLayout(self.selInfoWidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.selDescLabel = QtGui.QLabel(self.selInfoWidget)
self.selDescLabel.setText("")
self.selDescLabel.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
self.selDescLabel.setWordWrap(True)
self.selDescLabel.setObjectName("selDescLabel")
self.gridLayout.addWidget(self.selDescLabel, 0, 0, 1, 1)
self.selNameLabel = QtGui.QLabel(self.selInfoWidget)
font = QtGui.QFont()
font.setWeight(75)
font.setBold(True)
self.selNameLabel.setFont(font)
self.selNameLabel.setText("")
self.selNameLabel.setObjectName("selNameLabel")
self.gridLayout.addWidget(self.selNameLabel, 0, 1, 1, 1)
self.selectedTree = DataTreeWidget(self.selInfoWidget)
self.selectedTree.setObjectName("selectedTree")
self.selectedTree.headerItem().setText(0, "1")
self.gridLayout.addWidget(self.selectedTree, 1, 0, 1, 2)
self.hoverText = QtGui.QTextEdit(Form)
self.hoverText.setGeometry(QtCore.QRect(0, 240, 521, 81))
self.hoverText.setObjectName("hoverText")
self.view = FlowchartGraphicsView(Form)
self.view.setGeometry(QtCore.QRect(0, 0, 256, 192))
self.view.setObjectName("view")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def setupUi(self, MainWindow):
"""Setting up UI for Main Window
"""
MainWindow.setObjectName("MainWindow")
MainWindow.resize(804, 600)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.horizontalLayout = QtGui.QHBoxLayout(self.centralwidget)
self.horizontalLayout.setObjectName("horizontalLayout")
self.txtInput = QtGui.QPlainTextEdit(self.centralwidget)
self.txtInput.setObjectName("MarkDtextEdit")
self.horizontalLayout.addWidget(self.txtInput)
self.txtOutput = QtGui.QTextEdit(self.centralwidget)
self.txtOutput.setObjectName("MarkDownView")
self.horizontalLayout.addWidget(self.txtOutput)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 804, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def __init__(self, categoryID, parent=None):
QtGui.QDialog.__init__(self, parent)
self.setWindowTitle(u'Update category')
self.categoryID = categoryID
categoryData = readCategories()[self.categoryID]
#
self.categoryName = QtGui.QLineEdit('')
self.categoryName.setStyleSheet('background-color:#FFF;')
self.categoryName.setText(categoryData[0])
self.categoryDescription = QtGui.QTextEdit('')
self.categoryDescription.setText(categoryData[1])
# buttons
buttons = QtGui.QDialogButtonBox()
buttons.setOrientation(QtCore.Qt.Vertical)
buttons.addButton("Cancel", QtGui.QDialogButtonBox.RejectRole)
buttons.addButton("Update", QtGui.QDialogButtonBox.AcceptRole)
self.connect(buttons, QtCore.SIGNAL("accepted()"), self, QtCore.SLOT("accept()"))
self.connect(buttons, QtCore.SIGNAL("rejected()"), self, QtCore.SLOT("reject()"))
#
lay = QtGui.QGridLayout(self)
lay.addWidget(QtGui.QLabel(u'Name'), 0, 0, 1, 1)
lay.addWidget(self.categoryName, 0, 1, 1, 1)
lay.addWidget(QtGui.QLabel(u'Desctiption'), 1, 0, 1, 1, QtCore.Qt.AlignTop)
lay.addWidget(self.categoryDescription, 1, 1, 1, 1)
lay.addWidget(buttons, 0, 2, 2, 1, QtCore.Qt.AlignCenter)
lay.setRowStretch(1, 10)
def keyPressEvent(self,event):
if event.key() == QtCore.Qt.Key_Return and event.modifiers() == QtCore.Qt.META:
event.ignore()
else:
QtGui.QTextEdit.keyPressEvent(self,event)
def initUI(self):
self._layout = QtGui.QGridLayout()
self.setLayout(self._layout)
self._layout.setContentsMargins(5,5,5,5)
self._layout.setSpacing(0)
self._tabBar = QPanelTabBar()
_mainWidget = QtGui.QTextEdit()
self._layout.addWidget(self._tabBar,0,0)
self._layout.addWidget(_mainWidget,1,0,1,4)
def changeTab(self, index):
if index == self.count()-1:
if self.parent() != None:
t = QtGui.QTextEdit("New Tab")
self.parent().addPanel(t,"New Tab")
if self.parent() != None:
self.parent().setCurrentTab(index)
def start(self):
# Place widget in the layout
self.gridLayout = QtGui.QGridLayout(self)
self.gridLayout.setSpacing(5)
self.console = QtGui.QTextEdit()
self.console.setReadOnly(True)
self.startButton = QtGui.QPushButton("Start")
self.stopButton = QtGui.QPushButton("Stop")
self.quitButton = QtGui.QPushButton("Quit")
self.startButton.clicked.connect(self.startSlave)
self.stopButton.clicked.connect(self.stopSlave)
self.quitButton.clicked.connect(self.quitRenderSlaveUI)
self.gridLayout.addWidget(self.console,1,0,1,4)
self.gridLayout.addWidget(self.startButton,2,0,1,1)
self.gridLayout.addWidget(self.stopButton,2,1,1,1)
self.gridLayout.addWidget(self.quitButton,2,3,1,1)
self.setWindowTitle('sRender Slave')
self.setGeometry(0, 0, 500, 400)
self.show()
self.startSlave()
def build_ui(self):
self.setLayout(QtGui.QVBoxLayout())
self.label = QtGui.QLabel("some label")
self.btn = QtGui.QPushButton("button")
self.lineedit = QtGui.QLineEdit()
self.textedit = QtGui.QTextEdit()
self.grp = QtGui.QGroupBox("group box grid layout")
self.grp.setLayout(QtGui.QGridLayout())
self.chkbx_1 = QtGui.QCheckBox("chkbx_1")
self.chkbx_2 = QtGui.QCheckBox("chkbx_2l")
self.chkbx_2.setDisabled(True)
self.chkbx_3 = QtGui.QCheckBox("chkbx_2r")
self.chkbx_4 = QtGui.QCheckBox("chkbx_3")
self.chkbx_5 = QtGui.QCheckBox("chkbx_4")
self.grp.layout().addWidget(self.chkbx_1, 0, 0)
self.grp.layout().addWidget(self.chkbx_2, 1, 0)
self.grp.layout().addWidget(self.chkbx_3, 1, 1)
self.grp.layout().addWidget(self.chkbx_4, 2, 0)
self.grp.layout().addWidget(self.chkbx_5, 3, 0)
self.grp.layout().setColumnStretch(2,1)
self.lrbox = QtGui.QHBoxLayout()
self.lrbox.addWidget(self.textedit)
self.lrbox.addWidget(self.grp)
self.layout().addWidget(self.label)
self.layout().addWidget(self.btn)
self.layout().addWidget(self.lineedit)
self.layout().addLayout(self.lrbox)
def build_ui(self):
self.setLayout(QtGui.QVBoxLayout())
self.label = QtGui.QLabel("some label")
self.btn = QtGui.QPushButton("button")
self.lineedit = QtGui.QLineEdit()
self.textedit = QtGui.QTextEdit()
self.grp = QtGui.QGroupBox("group box grid layout")
self.grp.setLayout(QtGui.QGridLayout())
self.chkbx_1 = QtGui.QCheckBox("chkbx_1")
self.chkbx_2 = QtGui.QCheckBox("chkbx_2l")
self.chkbx_2.setDisabled(True)
self.chkbx_3 = QtGui.QCheckBox("chkbx_2r")
self.chkbx_4 = QtGui.QCheckBox("chkbx_3")
self.chkbx_5 = QtGui.QCheckBox("chkbx_4")
self.grp.layout().addWidget(self.chkbx_1, 0, 0)
self.grp.layout().addWidget(self.chkbx_2, 1, 0)
self.grp.layout().addWidget(self.chkbx_3, 1, 1)
self.grp.layout().addWidget(self.chkbx_4, 2, 0)
self.grp.layout().addWidget(self.chkbx_5, 3, 0)
self.grp.layout().setColumnStretch(2,1)
self.lrbox = QtGui.QHBoxLayout()
self.lrbox.addWidget(self.textedit)
self.lrbox.addWidget(self.grp)
self.layout().addWidget(self.label)
self.layout().addWidget(self.btn)
self.layout().addWidget(self.lineedit)
self.layout().addLayout(self.lrbox)
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 clearReportView(name):
from PySide import QtGui
mw=Gui.getMainWindow()
r=mw.findChild(QtGui.QTextEdit, "Report view")
r.clear()
import time
now = time.ctime(int(time.time()))
App.Console.PrintWarning("Cleared Report view " +str(now)+" by " + name+"\n")
def __init__ (self, errors, parent = None) :
#super (ErrorsDialog, self).__init__ ()
super (ErrorsDialog, self).__init__ (parent)
errors.reverse ()
self.parent = parent
#print self.parent.current_file, self.parent.current_list
self.setAttribute (QtCore.Qt.WA_DeleteOnClose)
saveAction = QtGui.QAction('Save log...', self)
saveAction.setShortcut('Ctrl+S')
saveAction.setStatusTip('Save displayed log file.')
saveAction.triggered.connect(self.saveFile)
saveErrAction = QtGui.QAction('Save unprocessed list...', self)
saveErrAction.setShortcut('Ctrl+U')
saveErrAction.setStatusTip('Save a list of unprocessed raw files.')
saveErrAction.triggered.connect(self.saveErrFile)
closeAction = QtGui.QAction('Close', self)
closeAction.setShortcut('Ctrl+Q')
closeAction.setStatusTip('Close error display')
closeAction.triggered.connect(self.close)
menubar = self.menuBar()
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(saveAction)
fileMenu.addAction (saveErrAction)
fileMenu.addAction(closeAction)
self.text = QtGui.QTextEdit(self)
self.setCentralWidget(self.text)
self.setGeometry(300,300,800,300)
self.setWindowTitle('Errors X')
self.show()
self.setIt (errors)
self.whatsLeft ()
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 __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent)
self.setWindowTitle(u"Export hole locations report")
# Output directory
self.pathToFile = QtGui.QLineEdit('')
self.pathToFile.setReadOnly(True)
zmianaSciezki = QtGui.QPushButton('...')
zmianaSciezki.setToolTip(u'Change path')
QtCore.QObject.connect(zmianaSciezki, QtCore.SIGNAL("pressed ()"), self.zmianaSciezkiF)
# header
icon = QtGui.QLabel('')
icon.setPixmap(QtGui.QPixmap(":/data/img/drill-icon.png"))
headerWidget = QtGui.QWidget()
headerWidget.setStyleSheet("padding: 10px; border-bottom: 1px solid #dcdcdc; background-color:#FFF;")
headerLay = QtGui.QGridLayout(headerWidget)
headerLay.addWidget(icon, 0, 0, 1, 1)
headerLay.setContentsMargins(0, 0, 0, 0)
# buttons
saveButton = QtGui.QPushButton(u"Export")
self.connect(saveButton, QtCore.SIGNAL("clicked ()"), self, QtCore.SLOT("accept()"))
closeButton = QtGui.QPushButton(u"Close")
self.connect(closeButton, QtCore.SIGNAL("clicked ()"), self, QtCore.SLOT('close()'))
packageFooter = QtGui.QHBoxLayout()
packageFooter.addStretch(10)
packageFooter.addWidget(saveButton)
packageFooter.addWidget(closeButton)
packageFooter.setContentsMargins(10, 0, 10, 10)
# report
self.reportPrev = QtGui.QTextEdit()
########
centerLay = QtGui.QGridLayout()
centerLay.addWidget(QtGui.QLabel(u'Output directory:'), 0, 0, 1, 1)
centerLay.addWidget(self.pathToFile, 0, 1, 1, 1)
centerLay.addWidget(zmianaSciezki, 0, 2, 1, 1)
centerLay.addWidget(self.reportPrev, 1, 0, 1, 3)
centerLay.setContentsMargins(10, 20, 10, 20)
mainLay = QtGui.QVBoxLayout(self)
mainLay.addWidget(headerWidget)
mainLay.addLayout(centerLay)
mainLay.addLayout(packageFooter)
mainLay.setContentsMargins(0, 0, 0, 0)
#
self.showReport()
def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent)
self.setWindowTitle(u"Centroid")
#
# Output directory
self.pathToFile = QtGui.QLineEdit('')
self.pathToFile.setReadOnly(True)
zmianaSciezki = QtGui.QPushButton('...')
zmianaSciezki.setToolTip(u'Change path')
QtCore.QObject.connect(zmianaSciezki, QtCore.SIGNAL("pressed ()"), self.zmianaSciezkiF)
# header
icon = QtGui.QLabel('')
icon.setPixmap(QtGui.QPixmap(":/data/img/exportBOM.png"))
headerWidget = QtGui.QWidget()
headerWidget.setStyleSheet("padding: 10px; border-bottom: 1px solid #dcdcdc; background-color:#FFF;")
headerLay = QtGui.QGridLayout(headerWidget)
headerLay.addWidget(icon, 0, 0, 1, 1)
headerLay.setContentsMargins(0, 0, 0, 0)
# buttons
saveButton = QtGui.QPushButton(u"Export")
self.connect(saveButton, QtCore.SIGNAL("clicked ()"), self, QtCore.SLOT("accept()"))
closeButton = QtGui.QPushButton(u"Close")
self.connect(closeButton, QtCore.SIGNAL("clicked ()"), self, QtCore.SLOT('close()'))
packageFooter = QtGui.QHBoxLayout()
packageFooter.addStretch(10)
packageFooter.addWidget(saveButton)
packageFooter.addWidget(closeButton)
packageFooter.setContentsMargins(10, 0, 10, 10)
# report
self.reportPrev = QtGui.QTextEdit()
########
centerLay = QtGui.QGridLayout()
centerLay.addWidget(QtGui.QLabel(u'Output directory:'), 0, 0, 1, 1)
centerLay.addWidget(self.pathToFile, 0, 1, 1, 1)
centerLay.addWidget(zmianaSciezki, 0, 2, 1, 1)
centerLay.addWidget(self.reportPrev, 1, 0, 1, 3)
centerLay.setContentsMargins(10, 20, 10, 20)
mainLay = QtGui.QVBoxLayout(self)
mainLay.addWidget(headerWidget)
mainLay.addLayout(centerLay)
mainLay.addLayout(packageFooter)
mainLay.setContentsMargins(0, 0, 0, 0)
#
self.showReport()
def _create_layouts_and_widgets(self):
self._logo = QtGui.QLabel()
self._logo.setPixmap(QtGui.QPixmap("images/logo.png"))
self._explanation = QtGui.QTextEdit("This tool is a thank-you to supporters of "
"upload.farm.<br><br>It allows you to automatically backup your Stardew Valley "
"savegames and upload them to upload.farm for safekeeping.<br><br>To begin using "
"the uploader, please authenticate with your upload.farm account by pressing "
"the button below, or by navigating to:<br><br>{}".format(AUTHENTICATION_URL))
self._explanation.setReadOnly(True)
self._profile_button = QtGui.QPushButton("&Authenticate")
self._profile_button.clicked.connect(self.open_api_auth)
self._help_button = QtGui.QPushButton("&Help!")
self._help_button.clicked.connect(self.open_help)
self._vbox = QtGui.QVBoxLayout()
self._vbox.addStretch(1)
logobox = QtGui.QHBoxLayout()
logobox.addStretch(1)
logobox.addWidget(self._logo)
logobox.addStretch(1)
self._vbox.addLayout(logobox)
self._vbox.addStretch(1)
logobox = QtGui.QHBoxLayout()
logobox.addStretch(1)
logobox.addWidget(self._explanation)
logobox.addStretch(1)
self._vbox.addLayout(logobox)
self._vbox.addStretch(1)
logobox = QtGui.QHBoxLayout()
logobox.addStretch(1)
logobox.addWidget(self._profile_button)
logobox.addWidget(self._help_button)
logobox.addStretch(1)
self._vbox.addLayout(logobox)
self._vbox.addStretch(1)
self._main_widget = QtGui.QWidget()
self._main_widget.setLayout(self._vbox)
self._main_widget.setMinimumWidth(500)
self._main_widget.setMinimumHeight(400)
self.setCentralWidget(self._main_widget)
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 createMessageGroupBox(self):
self.messageGroupBox = QtGui.QGroupBox("Balloon Message")
typeLabel = QtGui.QLabel("Type:")
self.typeComboBox = QtGui.QComboBox()
self.typeComboBox.addItem("None", QtGui.QSystemTrayIcon.NoIcon)
self.typeComboBox.addItem(self.style().standardIcon(
QtGui.QStyle.SP_MessageBoxInformation), "Information",
QtGui.QSystemTrayIcon.Information)
self.typeComboBox.addItem(self.style().standardIcon(
QtGui.QStyle.SP_MessageBoxWarning), "Warning",
QtGui.QSystemTrayIcon.Warning)
self.typeComboBox.addItem(self.style().standardIcon(
QtGui.QStyle.SP_MessageBoxCritical), "Critical",
QtGui.QSystemTrayIcon.Critical)
self.typeComboBox.setCurrentIndex(1)
self.durationLabel = QtGui.QLabel("Duration:")
self.durationSpinBox = QtGui.QSpinBox()
self.durationSpinBox.setRange(5, 60)
self.durationSpinBox.setSuffix(" s")
self.durationSpinBox.setValue(15)
durationWarningLabel = QtGui.QLabel("(some systems might ignore this "
"hint)")
durationWarningLabel.setIndent(10)
titleLabel = QtGui.QLabel("Title:")
self.titleEdit = QtGui.QLineEdit("Cannot connect to network")
bodyLabel = QtGui.QLabel("Body:")
self.bodyEdit = QtGui.QTextEdit()
self.bodyEdit.setPlainText("Don't believe me. Honestly, I don't have "
"a clue.\nClick this balloon for details.")
self.showMessageButton = QtGui.QPushButton("Show Message")
self.showMessageButton.setDefault(True)
messageLayout = QtGui.QGridLayout()
messageLayout.addWidget(typeLabel, 0, 0)
messageLayout.addWidget(self.typeComboBox, 0, 1, 1, 2)
messageLayout.addWidget(self.durationLabel, 1, 0)
messageLayout.addWidget(self.durationSpinBox, 1, 1)
messageLayout.addWidget(durationWarningLabel, 1, 2, 1, 3)
messageLayout.addWidget(titleLabel, 2, 0)
messageLayout.addWidget(self.titleEdit, 2, 1, 1, 4)
messageLayout.addWidget(bodyLabel, 3, 0)
messageLayout.addWidget(self.bodyEdit, 3, 1, 2, 4)
messageLayout.addWidget(self.showMessageButton, 5, 4)
messageLayout.setColumnStretch(3, 1)
messageLayout.setRowStretch(4, 1)
self.messageGroupBox.setLayout(messageLayout)
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 __init__(self, parent = None):
path = os.path.dirname(ui.__file__)
# chat
self.message_window_path = os.path.join(path, "message_window.ui")
self.chat_main_path = os.path.join(path, "chat_dialog.ui")
self.chat_add_topic_path = os.path.join(path, "chat_add_topic.ui")
self.chat_img_viewer_path = os.path.join(path, "chat_img_viewer.ui")
# moduls
self.db_studio = db.studio()
self.db_artist = db.artist()
self.db_task = db.task()
self.db_log = db.log()
self.db_chat = db.chat()
# get data
home_dir = os.path.expanduser('~')
json_path = os.path.normpath(os.path.join(home_dir, '.blend_chat.json'))
with open(json_path, 'r') as read:
data_dict = json.load(read)
self.chat_status = 'user'
self.current_task = data_dict['current_task']
self.current_user = data_dict['current_user']
self.current_project = data_dict['current_project']
print(data_dict)
# create widget
QtGui.QMainWindow.__init__(self, parent)
self.setWindowTitle('Chat Message Window')
self.textBox = QtGui.QTextEdit(parent = self)
self.textBox.setReadOnly(True)
self.setCentralWidget(self.textBox)
'''
# test text
text = self.textBox.toPlainText()
text = text + '\n' + '>>> ' + 'text.text'
self.textBox.setPlainText(text)
'''
self.run_chat_ui()