本文整理匯總了Python中gui.Ui_MainWindow類的典型用法代碼示例。如果您正苦於以下問題:Python Ui_MainWindow類的具體用法?Python Ui_MainWindow怎麽用?Python Ui_MainWindow使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Ui_MainWindow類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: principal
class principal(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.ventana = Ui_MainWindow()
self.ventana.setupUi(self)
command = 'systemctl is-active firewalld.service'
serviceStatus = os.system(command)
if serviceStatus == 0:
self.ventana.label_2.setText("<html><head/><body><p><span style=\" font-size:12pt; font-weight:600;\">Activado</span></p></body></html>")
self.ventana.pushButton.setText("Desactivar")
self.connect(self.ventana.pushButton, QtCore.SIGNAL('clicked()'), self.switch)
def switch(self):
command = 'systemctl is-active firewalld.service'
serviceStatus = os.system(command)
if serviceStatus == 0:
os.system('beesu systemctl stop firewalld.service')
self.ventana.label_2.setText("<html><head/><body><p><span style=\" font-size:12pt; font-weight:600; color:#FF0000\">Desactivado</span></p></body></html>")
self.ventana.pushButton.setText("Activar")
elif serviceStatus == 768:
os.system('beesu systemctl start firewalld.service')
self.ventana.label_2.setText("<html><head/><body><p><span style=\" font-size:12pt; font-weight:600;\">Activado</span></p></body></html>")
self.ventana.pushButton.setText("Desactivar")
示例2: MyForm
class MyForm(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
#buttons
self.ui.browsebutton.clicked.connect(self.set_directory)
self.ui.clearbutton.clicked.connect(self.clear_directory)
def set_directory(self):
self.ui.directorybox.clear()
self.ui.directorybox.setText(QFileDialog.getExistingDirectory())
self.display_scripts()
def clear_directory(self):
self.ui.scriptlist.clear()
self.ui.directorybox.clear()
def display_scripts(self):
self.ui.scriptlist.clear()
path = self.ui.directorybox.text()
os.chdir(path)
filelist = os.listdir()
for i in filelist:
if(i.endswith('.py')):
self.ui.scriptlist.append(i)
示例3: MyForm
class MyForm(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
QtCore.QObject.connect(self.ui.pushButton_2, QtCore.SIGNAL("clicked()"), self.on_first_clicked )
QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.on_second_clicked)
QtCore.QObject.connect(self.ui.pushButton_3, QtCore.SIGNAL("clicked()"), self.on_merge_clicked)
def on_first_clicked(self):
File1 = QtGui.QFileDialog.getOpenFileName();
self.ui.lineEdit_2.setText(File1)
def on_second_clicked(self):
File2 = QtGui.QFileDialog.getOpenFileName();
self.ui.lineEdit.setText(File2)
def on_merge_clicked(self):
File1 = self.ui.lineEdit_2.text()
File2 = self.ui.lineEdit.text()
if File1 and File2:
merge(File1, File2)
else:
print('specify a file')
def add_entry(self):
self.ui.lineEdit.selectAll()
self.ui.lineEdit.cut()
self.ui.textEdit.append("")
self.ui.textEdit.paste()
示例4: ControlMainWindow
class ControlMainWindow(QtGui.QMainWindow):
def __init__(self, parent=None):
super(ControlMainWindow, self).__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
def customSetUp(self):
initialize_map()
table = self.ui.mainboard
table.setRowCount(upper_limit_x())
table.setColumnCount(upper_limit_y())
table.setHorizontalHeaderLabels(('0', '1', '2' , '3' , '4' ,'5'))
table.setVerticalHeaderLabels(('0', '1', '2' , '3' , '4' ,'5'))
table.cellClicked.connect(handleTableClick)
#(y,x)
#table.setItem(origin.y, origin.x, QtGui.QTableWidgetItem())
#table.item(origin.y, origin.x).setBackground(QtGui.QColor(100,100,150))
#table.setItem(finish.y, finish.x, QtGui.QTableWidgetItem())
#table.item(finish.y, finish.x).setBackground(QtGui.QColor(100,100,150))
self.ui.solveButton.clicked.connect(start_a_star)
self.ui.cleanButton.clicked.connect(action_clean_board)
self.ui.randomButton.clicked.connect(create_random_map)
QtCore.QObject.connect(self.ui.aboutASTAR, QtCore.SIGNAL('triggered()'), action_about_a_star)
QtCore.QObject.connect(self.ui.actionNewMap, QtCore.SIGNAL('triggered()'), action_new_map)
clean_board()
示例5: MyForm
class MyForm(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
QtCore.QObject.connect(self.ui.goto_channel_0,
QtCore.SIGNAL("clicked()"), self.move_program_to_channel) # lint:ok
QtCore.QObject.connect(self.ui.create_null,
QtCore.SIGNAL("clicked()"), self.create_null) # lint:ok
# Create a QTimer
self.channel_timer = QtCore.QTimer()
# Connect it to f
self.channel_timer.timeout.connect(self.update_gui)
# Call f() every 5 seconds
self.channel_timer.start(1000)
def update_sinks(self, sink_inputs):
for sink in sink_inputs:
old_items = self.ui.sinks.findItems(sink['appname'], QtCore.Qt.MatchFixedString)
if not old_items:
item = QtGui.QListWidgetItem("%s" % sink['appname'])
self.ui.sinks.addItem(item)
for index in range(self.ui.sinks.count()):
item = self.ui.sinks.item(index)
found = False
for sink in sink_inputs:
if sink['appname'] == item.text():
found = True
if not found:
self.ui.sinks.takeItem(index)
def update_channels(self, channels):
for channel in channels:
item = QtGui.QListWidgetItem("%s" % channel['name'])
self.ui.channel1.addItem(item)
if channel['name'] == 'streamer':
self.ui.create_null.setEnabled(False)
def update_gui(self):
self.update_sinks(get_active_player_programs())
def move_program_to_channel(self):
return
def create_null(self):
cmd = ["pactl"]
paramter = ["load-module", "module-null-sink", "sink_name=streamer"]
try:
sink_number = subprocess.call(cmd + paramter)
except OSError as e:
print >>sys.stderr, "Execution failed:", e
示例6: Main
class Main(QMainWindow):
def __init__(self, parent):
super(Main, self).__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.textEdit.initInterpreter(locals())
self.ui.textEdit.updateInterpreterLocals(self.ui.dockWidget)
示例7: main
def main():
app = QtGui.QApplication(sys.argv)
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
示例8: StartQT4
class StartQT4(QtGui.QMainWindow):
def __init__(self, parent = None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
# Force consistent theme and font size
QtGui.QApplication.setStyle(QtGui.QStyleFactory.create("Plastique"))
# Disable resizing
self.setFixedSize(self.size())
#######################################################
# Interface Object Connections #
#######################################################
itemClicked = QtCore.SIGNAL("itemClicked(QListWidgetItem *)")
clicked = QtCore.SIGNAL("clicked()")
## Buttons
QtCore.QObject.connect(self.ui.pushButton_convert, clicked, self.convertImage)
QtCore.QObject.connect(self.ui.pushButton_loadImage, clicked, self.loadImage)
def loadImage(self):
imageName = str(QtGui.QFileDialog.getOpenFileName())
self.ui.label_imageFile.setText(imageName)
def convertImage(self):
imageName = str(self.ui.label_imageFile.text())
imageTitle = self.ui.lineEdit_title.text()
if not imageTitle == '':
filename, extension = os.path.splitext(imageName)
directory, file = os.path.split(filename)
image = Image.open(imageName)
#scale image
imageWidth, imageHeight = image.size
ratio = min(128/imageWidth, 98/imageHeight)
newImageHeight = int(imageHeight*ratio)
newImageWidth = int(imageWidth*ratio)
size = newImageWidth, newImageHeight
image = image.resize(size)
#add white bar to bottom for text
horizontalImageSpacing = int((128-newImageWidth)/2)
image = image.crop(( -1*horizontalImageSpacing,0,newImageWidth+horizontalImageSpacing,128))
draw = ImageDraw.Draw(image)
myFont = ImageFont.truetype("Arial.ttf", 20, encoding="unic")
textWidth, textHeight = myFont.getsize(imageTitle)
textHorizontalPosition = 64 - (textWidth/2)
textVerticalPosition = 98 + (15 - (textHeight/2))
draw.text((textHorizontalPosition, textVerticalPosition), imageTitle, fill="white", font=myFont)
image = image.convert("RGB")
#convert to png
validFileName = ''.join(c for c in imageTitle if not c in NonValidChars)
image.save(os.path.join(directory, validFileName) + ".png", quality=100)
QtGui.QMessageBox.information(self, "Image Converted", "The image has been converted and is ready for use on the Sifteo Cubes")
示例9: MyForm
class MyForm(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
''' Examples of connecting signals (assumes your form has a pushButton, lineEdit, and textEdit)
self.ui.pushButton.clicked.connect(self.ui.textEdit.clear)
self.ui.lineEdit.returnPressed.connect(self.add_entry)
'''
''' Example of signal callback (performed when return is pressed on lineEdit, see above)
示例10: __init__
def __init__(self, dialog):
Ui_MainWindow.__init__(self)
self.setupUi(dialog)
self.scriptOpen.clicked.connect(self.getFileName)
self.targetOpen.clicked.connect(self.getTargetName)
self.convertPy.clicked.connect(self.pyConvert)
self.process = QtCore.QProcess()
self.process.readyRead.connect(self.dataReady)
self.process.started.connect(lambda: self.convertPy.setEnabled(False))
self.process.finished.connect(lambda: self.convertPy.setEnabled(True))
示例11: __init__
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
#buttons
self.ui.browsebutton.clicked.connect(self.set_directory)
self.ui.clearbutton.clicked.connect(self.clear_directory)
示例12: __init__
def __init__(self, app, parent=None):
super(blueCat, self).__init__(parent)
print("Ala ma kota")
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.bt = Bt()
self.bt.new_beacon.connect(self.receive_beacon)
self.blueNode = BlueNode('login', 'password') # add your login
self.blueNode.new_data.connect(self.receive_node)
self.detected_devices = []
self.monitored_devices = []
self.devices_live_time = 10 # after this amount of seconds of inactivity device is lost....
self.timer_delete_old_devices = QtCore.QTimer()
QtCore.QObject.connect(self.timer_delete_old_devices, QtCore.SIGNAL('timeout()'), self.delete_old_devices)
# self.timer_delete_old_devices.start(self.devices_live_time*1000)
# GUI
QtCore.QObject.connect(self.ui.pushButton_add, QtCore.SIGNAL('clicked()'), self.button_add)
QtCore.QObject.connect(self.ui.pushButton_connect, QtCore.SIGNAL('clicked()'), self.button_connect)
self.ui.lineEdit_name.setText("Beacon1")
self.ui.lineEdit_location.setText("Reaktor")
示例13: __init__
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.ventana = Ui_MainWindow()
self.ventana.setupUi(self)
self.model = QtSql.QSqlQueryModel(self)
#Create Objects
self.adding = adding()
self.searching = searching()
self.modifying = modifying()
self.deleting = deleting()
#TableView Initial
self.model.setQuery("SELECT nombre, ap_paterno, ap_materno, edad, fecha_registro, grado, grupo FROM alumno JOIN escolares USING(id_alumno);")
self.view = self.ventana.tableView
self.view.setModel(self.model)
#Toolbar SIGNAL's
self.connect(self.ventana.actionAgregar, QtCore.SIGNAL('activated()'), self.agregar)
self.connect(self.ventana.actionBuscar, QtCore.SIGNAL('activated()'), self.buscar)
self.connect(self.ventana.actionEditar, QtCore.SIGNAL('activated()'), self.editar)
self.connect(self.ventana.actionBorrar, QtCore.SIGNAL('activated()'), self.borrar)
#Query SIGNAL's
self.connect(self.adding, QtCore.SIGNAL('agregado'), self.insertar)
self.connect(self.searching, QtCore.SIGNAL('buscado'), self.consultar)
self.connect(self.modifying, QtCore.SIGNAL('editado'), self.actualizar)
self.connect(self.deleting, QtCore.SIGNAL('borrado'), self.eliminar)
示例14: __init__
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.tv1model = QStandardItemModel()
self.tv2model = QStandardItemModel()
self.chami = Chami()
self.db = self.chami.db
self.setMyCoursesTreeView()
self.setAllCoursesTreeView()
# Starts the url consommer/downloader thread/queue
self.downloader = Downloader()
self.downloader.updateProgress.connect(self.set_progress)
self.downloader.start()
self.ui.downloadButton.setEnabled(False)
self.ui.downloadButton.clicked.connect(lambda: self.download())
self.ui.connectButton.clicked.connect(lambda: self.connect())
self.ui.searchButton.clicked.connect(lambda: self.search())
self.ui.searchLineEdit.returnPressed.connect(lambda: self.search())
self.ui.passLineEdit.returnPressed.connect(lambda: self.connect())
self.ui.action_Update_db.triggered.connect(lambda: self.update_db())
示例15: __init__
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
#Create Video Object
cv2.namedWindow('Video')
device = 0
self.video = cv2.VideoCapture(device)
#Set up timer
self.ctimer = QtCore.QTimer()
#Slider Bars signal connectors
QtCore.QObject.connect(self.ui.horizontalSlider, QtCore.SIGNAL("sliderMoved(int)"),self.updateLabels)
QtCore.QObject.connect(self.ui.horizontalSlider_2, QtCore.SIGNAL("sliderMoved(int)"),self.updateLabels)
QtCore.QObject.connect(self.ui.horizontalSlider_3, QtCore.SIGNAL("sliderMoved(int)"),self.updateLabels)
QtCore.QObject.connect(self.ui.horizontalSlider_4, QtCore.SIGNAL("sliderMoved(int)"),self.updateLabels)
QtCore.QObject.connect(self.ui.horizontalSlider_5, QtCore.SIGNAL("sliderMoved(int)"),self.updateLabels)
QtCore.QObject.connect(self.ui.horizontalSlider_6, QtCore.SIGNAL("sliderMoved(int)"),self.updateLabels)
#Timer signal
QtCore.QObject.connect(self.ctimer,QtCore.SIGNAL("timeout()"),self.tick)
#Timer start
self.ctimer.start(1)