def connection():
conn, data = SQL_Handler.connectToDatabase('fobs', form.UsernameField.text(), form.PasswordField.text(), 'localhost')
if conn is not None:
buildTable()
form.close()
form2.show()
form2.logoutButton.clicked.connect(mainMenu)
form2.refreshButton.clicked.connect(lambda: buildTable())
form2.validationButton.clicked.connect(lambda: saveChanges())
else:
Q = QMessageBox()
Q = QMessageBox.information(Q, 'Error', 'Connection failed.',
QMessageBox.Ok)
python类information()的实例源码
def submitContact(self):
name = self.nameLine.text()
address = self.addressText.toPlainText()
if name == "" or address == "":
QMessageBox.information(self, "Empty Field",
"Please enter a name and address.")
return
if name not in self.contacts:
self.contacts[name] = address
QMessageBox.information(self, "Add Successful",
"\"%s\" has been added to your address book." % name)
else:
QMessageBox.information(self, "Add Unsuccessful",
"Sorry, \"%s\" is already in your address book." % name)
return
if not self.contacts:
self.nameLine.clear()
self.addressText.clear()
self.nameLine.setReadOnly(True)
self.addressText.setReadOnly(True)
self.addButton.setEnabled(True)
self.submitButton.hide()
self.cancelButton.hide()
def change_status(self, rowid):
"""
Description: If the user clicks on the column which determines VM's status, we'll allow them
to change VM's status. This method shows a confirmation dialog and if accepted,
it will be notified to oVirt.
Arguments: The row id that has been clicked. This relationship is stored using the VmData class.
Returns: Nothing
"""
global conf
self.lastclick = int(time()) # Last click timestamp update
curvmstatus = self.vmdata[rowid].vmstatus
if curvmstatus != 'up' and curvmstatus != 'down':
QMessageBox.warning(None, _('apptitle') + ': ' + _('warning'), _('vm_in_unchangeable_status'))
return
reply = QMessageBox.question(None, _('apptitle') + ': ' + _('confirm'), '%s <b>%s</b>. %s: <b>%s</b>.' % (_('current_vm_status'), self.current_vm_status(curvmstatus), _('confirm_vm_status_change'), self.toggle_vm_action(curvmstatus)), QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
if reply == QMessageBox.Yes:
try:
vm = conf.OVIRTCONN.vms.get(id=self.vmdata[rowid].vmid)
except ConnectionError:
QMessageBox.critical(None, _('apptitle') + ': ' + _('error'), _('unexpected_connection_drop'))
quit()
if curvmstatus == 'up':
try:
vm.shutdown()
QMessageBox.information(None, _('apptitle') + ': ' + _('success'), _('shutting_down_vm'))
except RequestError:
QMessageBox.warning(None, _('apptitle') + ': ' + _('warning'), _('vm_in_unchangeable_status'))
if curvmstatus == 'down':
try:
vm.start()
QMessageBox.information(None, _('apptitle') + ': ' + _('success'), _('powering_up_vm'))
except RequestError:
QMessageBox.warning(None, _('apptitle') + ': ' + _('warning'), _('vm_in_unchangeable_status'))
def submitContact(self):
name = self.nameLine.text()
address = self.addressText.toPlainText()
if name == "" or address == "":
QMessageBox.information(self, "Empty Field",
"Please enter a name and address.")
return
if name not in self.contacts:
self.contacts[name] = address
QMessageBox.information(self, "Add Successful",
"\"%s\" has been added to your address book." % name)
else:
QMessageBox.information(self, "Add Unsuccessful",
"Sorry, \"%s\" is already in your address book." % name)
return
if not self.contacts:
self.nameLine.clear()
self.addressText.clear()
self.nameLine.setReadOnly(True)
self.addressText.setReadOnly(True)
self.addButton.setEnabled(True)
self.submitButton.hide()
self.cancelButton.hide()
def help(self):
helpmsg = "It may be helpful to hover the mouse cursor over\n";
helpmsg += "items and text labels that you don't understand.";
QMessageBox.information(self,'Nonadiabatic help',helpmsg);
def no_user_selected(self):
reply = message.information(self, 'No User Selected', no_user_selected_message, message.Ok)
return reply == message.Ok
def no_subreddit_selected(self):
reply = message.information(self, 'No Subreddit Selected', no_subreddit_selected_message, message.Ok)
return reply == message.Ok
def failed_to_save(self):
reply = message.information(self, 'Save Failed', failed_to_save_message, message.Ok)
return reply == message.Ok
def remove_user(self):
reply = message.information(self, 'Remove User?', remove_user_message, message.Ok, message.Cancel)
return reply == message.Ok
def remove_subreddit(self):
reply = message.information(self, 'Remove Subreddit?', remove_subreddit_message, message.Ok, message.Cancel)
return reply == message.Ok
def subreddit_not_valid(self, sub):
text = '%s is not a valid subreddit. Would you like to remove this sub from the subreddit list?' % sub
reply = message.information(self, 'Invalid Subreddit', text, message.Yes, message.No)
return reply == message.Ok
def not_valid_name(self):
text = 'Sorry, that is not a valid name'
reply = message.information(self, 'Invalid Name', text, message.Ok)
return reply == message.Ok
def name_in_list(self):
text = 'That name is already in the list'
reply = message.information(self, 'Existing Name', text, message.Ok)
return reply == message.Ok
def no_user_download_folder(self):
text = 'The user you selected does not appear to have a download folder. This is likely because nothing has ' \
'been downloaded for this user yet.'
reply = message.information(self, 'Folder Does Not Exist', text, message.Ok)
return reply == message.Ok
def no_subreddit_download_folder(self):
text = 'The subreddit you selected does not appear to have a download folder. This is likely because nothing ' \
'has been downloaded for this subreddit yet.'
reply = message.information(self, 'Folder Does Not Exist', text, message.Ok)
return reply == message.Ok
def nothing_to_download(self):
text = 'Nothing to download. Please add users or subreddits you would like to download from.'
reply = message.information(self, 'Nothing to Download', text, message.Ok)
return reply == message.Ok
def no_imgur_client(self):
text = 'No Imgur client is detected. You must have an Imgur client in order to download content from ' \
'imgur.com. Please see settings menu and click on the "Imgur Client Information" in the top right for ' \
'instuctions on how to obtain an imgur client and enter its credentials for use with this application'
reply = message.information(self, 'No Imgur Client', text, message.Ok)
return reply == message.Ok
def invalid_imgur_client(self):
text = 'The Imgur client you are useing is not valid. Please see the imgur client dialog for instructions on ' \
'how to obtain a valid client id and secret. This dialog can be accessed through the settings menu'
reply = message.information(self, 'Invalid Imgur Client', text, message.Ok)
return reply == message.Ok
def user_manual_not_found(self):
text = 'The user manual cannot be found. This is most likely because the manual has been moved from the ' \
'expected location, or renamed to something the application is not expecting. To correct the issue ' \
'please move the user manual back to the source folder and ensure it is named ' \
'"The Downloader For Reddit - User Manual.pdf"'
reply = message.information(self, 'User Manual Not Found', text, message.Ok)
return reply == message.Ok
def up_to_date_message(self):
text = 'You are running the latest version of The Downloader for Reddit'
reply = message.information(self, 'Up To Date', text, message.Ok)
return reply == message.Ok
def showImage(self, text):
try:
if text == 'Show Red':
RPiCamera.showImage(self.rgb_array, 'r')
elif text == 'Show Green':
RPiCamera.showImage(self.rgb_array, 'g')
elif text == 'Show Blue':
RPiCamera.showImage(self.rgb_array, 'b')
else:
RPiCamera.showImage(self.rgb_array)
except ValueError:
mb = QMessageBox()
mb.setIcon(QMessageBox.Information)
mb.setWindowTitle('Error')
mb.setText('Array not loaded, make sure you take picture or import an image first.')
mb.setStandardButtons(QMessageBox.Ok)
mb.show()
def install(self):
infoBox = QMessageBox()
infoBox.setIcon(QMessageBox.Information)
infoBox.setText("Your programs are being installed.Please wait")
infoBox.setWindowTitle("Information")
infoBox.setStandardButtons(QMessageBox.Ok)
infoBox.exec_()
#BashCommands.StartRun()
self.getItems()
infoBox = QMessageBox()
infoBox.setIcon(QMessageBox.Information)
infoBox.setText("Your programs installed ")
infoBox.setWindowTitle("Information")
infoBox.setStandardButtons(QMessageBox.Ok)
infoBox.exec_()
# When clicked update button
def printAbout(self):
"""
Show window with about and version information.
"""
msgBox = QMessageBox(QMessageBox.Information, "About",
"About <b>" + basics.NAME + "</b>: <br><br>" + basics.NAME + " " +
"is a file encryption and decryption tool using a Trezor hardware "
"device for safety and security. Symmetric AES cryptography is used "
"at its core. <br><br>" +
"<b>" + basics.NAME + " Version: </b>" + basics.VERSION_STR +
" from " + basics.VERSION_DATE_STR +
"<br><br><b>Python Version: </b>" + sys.version.replace(" \n", "; ") +
"<br><br><b>Qt Version: </b>" + QT_VERSION_STR +
"<br><br><b>PyQt Version: </b>" + PYQT_VERSION_STR)
msgBox.setIconPixmap(QPixmap(basics.LOGO_IMAGE))
msgBox.exec_()
def update_database(self):
"""
Display the 'database update' dialog.
"""
self.show()
is_something_running = False
for x in B3App.Instance().processes:
if x.state() == QProcess.Running:
is_something_running = True
break
if is_something_running:
msgbox = QMessageBox()
msgbox.setIcon(QMessageBox.Information)
msgbox.setWindowTitle('NOTICE')
msgbox.setText('Some B3 processes are still running: you need to terminate them to update B3 database.')
msgbox.setStandardButtons(QMessageBox.Ok)
msgbox.exec_()
else:
update = UpdateDatabaseDialog(self.centralWidget())
update.show()
def tempPlot(self):
try:
self.y_title_axis = ['Temperature Plot', 'Temperature vs Time', 't(s)', 'T(C)', 'Sensor']
MultiPlot.Plot(self.tf, len(self.ids), self.y_title_axis)
except KeyError:
mb = QMessageBox()
mb.setIcon(QMessageBox.Information)
mb.setWindowTitle('Error')
mb.setText('No temperature sensor connected.')
mb.setStandardButtons(QMessageBox.Ok)
mb.show()
def pumppowerchange(self):
try:
if self.pumppwmvalue > 100:
raise ValueError
else:
self.PUMPPWM.setIntensity(self.pumppwmvalue)
except ValueError:
mb = QMessageBox()
mb.setIcon(QMessageBox.Information)
mb.setWindowTitle('Error')
mb.setText('Please type in a value between 0-100.')
mb.setStandardButtons(QMessageBox.Ok)
mb.show()
def showPlots(self):
try:
RPiCamera.showPlot(self.rgb_array)
self.statusbar = 'Ready'
except ValueError:
mb = QMessageBox()
mb.setIcon(QMessageBox.Information)
mb.setWindowTitle('Error')
mb.setText('Array not loaded, make sure you take picture or import an image first.')
mb.setStandardButtons(QMessageBox.Ok)
mb.show()
def spawn_window(parent, node, iface_name):
driver = node.can_driver
if not slcan_cli.CLIInterface.is_backend_supported(driver):
mbox = QMessageBox(parent)
mbox.setWindowTitle('Unsupported CAN Backend')
mbox.setText('CAN Adapter Control Panel cannot be used with the current CAN backend.')
mbox.setInformativeText('The current backend is %r.' % type(driver).__name__)
mbox.setIcon(QMessageBox.Information)
mbox.setStandardButtons(QMessageBox.Ok)
mbox.show() # Not exec() because we don't want it to block!
return
progress_dialog = QProgressDialog(parent)
progress_dialog.setWindowTitle('CAN Adapter Control Panel Initialization')
progress_dialog.setLabelText('Detecting CAN adapter capabilities...')
progress_dialog.setMinimumDuration(800)
progress_dialog.setCancelButton(None)
progress_dialog.setRange(0, 0)
progress_dialog.show()
def supported_callback(supported):
progress_dialog.close()
if not supported:
mbox = QMessageBox(parent)
mbox.setWindowTitle('Incompatible CAN Adapter')
mbox.setText('CAN Adapter Control Panel cannot be used with the connected adapter.')
mbox.setInformativeText('Connected SLCAN adapter does not support CLI extensions.')
mbox.setIcon(QMessageBox.Information)
mbox.setStandardButtons(QMessageBox.Ok)
mbox.show() # Not exec() because we don't want it to block!
return
slcp = slcan_cli.ControlPanelWindow(parent, slcan_iface, iface_name)
slcp.show()
slcan_iface = slcan_cli.CLIInterface(driver)
slcan_iface.check_is_interface_supported(supported_callback)
def _write_example_data(self):
try:
mdt.utils.get_example_data(self.outputFile.text())
msg = QMessageBox()
msg.setIcon(QMessageBox.Information)
msg.setText('The MDT example data has been written to {}.'.format(self.outputFile.text()))
msg.setWindowTitle('Success')
msg.exec_()
except IOError as e:
msg = QMessageBox()
msg.setIcon(QMessageBox.Critical)
msg.setText(str(e))
msg.setWindowTitle("File writing error")
msg.exec_()
def update(self):
Update.Update()
infoBox = QMessageBox()
infoBox.setIcon(QMessageBox.Information)
infoBox.setText("Updated")
infoBox.setWindowTitle("Information")
infoBox.setStandardButtons(QMessageBox.Ok)
infoBox.exec_()
# When clicked about button