def languageselector(self, parent=None): QtGui.QWidget.__init__(self, None) from langselectui import Ui_MainWindow self.ui = Ui_MainWindow() self.ui.setupUi(self) self.show() QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.loadlanguage) clickable(self.ui.help).connect(self.webhelp) clickable(self.ui.checkupdatesBtn).connect(self.webupdate) clickable(self.ui.aboutBtn).connect(self.about) clickable(self.ui.translatenow).connect(self.translate) try: con = urllib.urlopen( "http://usbaktarici.googlecode.com/svn/trunk/version") data = con.read() con.close() if int(data) > version: self.onay = QtGui.QMessageBox.question( self, _fromUtf8('Warning'), _fromUtf8( "New version is available, do you want to download?"), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) if self.onay == QtGui.QMessageBox.Yes: webbrowser.open("http://www.oguzkirat.com/usb-transfer") except: pass
class mywindow(QtWidgets.QMainWindow): def __init__(self): super(mywindow, self).__init__() self.con = psycopg2.connect(dbname=config.db_name, user=config.user, password=config.password, host=config.host) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.SignIn_btn.clicked.connect(self.signin) self.ui.SignUp_btn.clicked.connect(self.signup) self.error_dialog = QtWidgets.QMessageBox() self.error_dialog.setWindowTitle("Error") self.error_dialog.setStandardButtons(QMessageBox.Ok) self.info_dialog = QtWidgets.QMessageBox() self.info_dialog.setWindowTitle('INFO') self.info_dialog.setStandardButtons(QMessageBox.Ok) def signup(self): cur = self.con.cursor() name = self.ui.Name_edit.text() midname = self.ui.Middle_Name_edit.text() surname = self.ui.Surname_edit.text() bdate = self.ui.Birthday_edit.text() #print(bdate) rgdate = get_current_time() #print(rgdate) email = self.ui.Email_edit.text() phone = self.ui.Phone_edit.text() login = self.ui.Login_edit.text() passwd = get_hash(self.ui.Password_edit.text()) SQL = f""" insert into User(Name,Middle_name,Surname,Birthdate,Reg_date,Email,Phone) VALUES('{name}','{midname}','{surname}','{bdate}','{rgdate}','{email}',{phone}); """ #print(SQL) cur.execute(SQL) SQL = f"""insert into secret(Login,Password,userid) values('{login}','{passwd}',{cur.lastrowid -1})""" #print(SQL) cur.execute(SQL) self.con.commit() def signin(self): login = self.ui.Login_edit_2.text() passwd = get_hash(self.ui.Password_edit_2.text()) cur = self.con.cursor() cur.execute( f"""select * from secret where Login = "******" and Password = "******";""" ) if len(cur.fetchall()) > 0: self.info_dialog.setText("Login Successful") self.info_dialog.exec_() else: self.error_dialog.setText("Login Failed") self.error_dialog.exec_()
def __init__(self, parent=None): super(UIPracticeWindow, self).__init__(parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) # User functions self.ui.pushButton.clicked.connect(self.printDennts) self.ui.clear.clicked.connect(self.cleartext) self.ui.pushButton.clicked.connect(self.printMessage)
def createfromdvd(self): if self.img_src != "" and self.disk_dest != "": if osystem == 'win32': self.disk_size = int(self.driveliste[int(self.disk_dest)][4]) self.img_size = (int(self.b.drives[self.img_src]['size']) * (1024 * 1024)) elif osystem == 'linux2': self.disk_size = (int(self.a.drives[self.disk_dest]['size'])) self.img_size = (int(self.b.drives[self.img_src]['size'])) if osystem == "win32": simg = "\\\\.\\" + self.img_src else: simg = self.img_src global sourceimg sourceimg = simg global targetdisk targetdisk = self.disk_dest global size size = self.img_size / (1024**2) if self.img_size > self.disk_size: req_size = ((self.img_size - self.disk_size) / mbyte) self.warning_dialog( self.tr("Error!"), self.tr("There is no enough space on the target disk!") + "\n" + str(req_size) + self.tr("MBs more needed.")) else: self.onay = QtGui.QMessageBox.question( self, self.tr('Warning'), self. tr("You will lose all the data in the disk. Do you want to continue?" ), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) if self.onay == QtGui.QMessageBox.Yes: from progressui import Ui_MainWindow self.hide() QtGui.QWidget.__init__(self, None) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.show() if osystem == "win32": self.preparewin(targetdisk) self.ui.thread = CopyProgress() self.ui.thread.partDone.connect(self.updatePBar) self.ui.thread.procDone.connect(self.fin) self.ui.thread.start() else: self.warning_dialog(self.tr("Canceled!"), self.tr("Transfer canceled!")) else: self.warning_dialog( self.tr("Cannot continue."), self.tr("CD/DVD drive or target disk wasn't selected!")) return True
def __init__(self): super(MyApp, self).__init__() self.logfile = '' self.ui = Ui_MainWindow() self.ui.setupUi(self) # self.ui.setupUiExt(self) # self.ui.setupWidget(self) self.initialize() self._setup_signal() self.drvlog = None self.activesensor = 'accelerometer'
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.main_frame = Ui_MainWindow() self.main_frame.setupUi(self) self.valueChanged = QtCore.Signal(int) timer = QtCore.QTimer(self) self.connect(timer, QtCore.SIGNAL("timeout()"), self.update) timer.start(speed)
def formatpage(self): self.disk_dest = "" from formatuiwin import Ui_MainWindow self.hide() QtGui.QWidget.__init__(self, None) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.show() QtCore.QObject.connect(self.ui.selectUSBButton, QtCore.SIGNAL("clicked()"), self.select_disk) QtCore.QObject.connect(self.ui.Btn_Back, QtCore.SIGNAL("clicked()"), self.backtomain) QtCore.QObject.connect(self.ui.Btn_formatStart, QtCore.SIGNAL("clicked()"), self.formatting)
def __init__(self): super(Appwindow, self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.timer = QTimer() # self.timer.timeout.connect(self.tick) self.timer.timeout.connect(self.UDP_Srver) self.ui.btn_start_udp_server.clicked.connect(self.buttonClicked) self.ui.btn_stop_udp_server.clicked.connect(self.btn_stop) # self.timer.stop() pyqtgraph.setConfigOption('background', 'w') #before loading widget self.t = np.array([0]) self.x = np.array([0]) self.pocket_num = 0
class MainWindow(QMainWindow, Ui_MainWindow): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.main_frame = Ui_MainWindow() self.main_frame.setupUi(self) self.valueChanged = QtCore.Signal(int) timer = QtCore.QTimer(self) self.connect(timer, QtCore.SIGNAL("timeout()"), self.update) timer.start(speed) def update(self): self.mainGuiController.timerEvent() def plot1(self, voiHistory, statesHistory, algebraicsHistory): self.main_frame.plotArea.axes.plot(voiHistory, np.vstack((statesHistory,algebraicsHistory)).T) self.main_frame.plotArea.draw() def reset(self, co2SinkValue, co2SourceValue, protonSourceValue): self.main_frame.plotArea.axes.clear() self.main_frame.plotArea.draw() self.main_frame.co2Sink.setValue(co2SinkValue) self.main_frame.co2Source.setValue(co2SourceValue) self.main_frame.protonSource.setValue(protonSourceValue) def setCo2SourceValue(self, value): self.main_frame.co2SourceValue.setText(str(value)) def setCo2SinkValue(self, value): self.main_frame.co2SinkValue.setText(str(value)) def setProtonSourceValue(self, value): self.main_frame.protonSourceValue.setText(str(value)) def playPauseLabelToggle(self, running): if (running): text = "Pause" else: text = "Run" self.main_frame.simulateButton.setText(text)
class MainWindow(QMainWindow, Ui_MainWindow): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.main_frame = Ui_MainWindow() self.main_frame.setupUi(self) self.valueChanged = QtCore.Signal(int) timer = QtCore.QTimer(self) self.connect(timer, QtCore.SIGNAL("timeout()"), self.update) timer.start(speed) def update(self): self.mainGuiController.timerEvent() def plot1(self, voiHistory, statesHistory, algebraicsHistory): self.main_frame.plotArea.axes.plot( voiHistory, np.vstack((statesHistory, algebraicsHistory)).T) self.main_frame.plotArea.draw() def reset(self, co2SinkValue, co2SourceValue, protonSourceValue): self.main_frame.plotArea.axes.clear() self.main_frame.plotArea.draw() self.main_frame.co2Sink.setValue(co2SinkValue) self.main_frame.co2Source.setValue(co2SourceValue) self.main_frame.protonSource.setValue(protonSourceValue) def setCo2SourceValue(self, value): self.main_frame.co2SourceValue.setText(str(value)) def setCo2SinkValue(self, value): self.main_frame.co2SinkValue.setText(str(value)) def setProtonSourceValue(self, value): self.main_frame.protonSourceValue.setText(str(value)) def playPauseLabelToggle(self, running): if (running): text = "Pause" else: text = "Run" self.main_frame.simulateButton.setText(text)
def __init__(self): super(mywindow, self).__init__() self.con = psycopg2.connect(dbname=config.db_name, user=config.user, password=config.password, host=config.host) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.SignIn_btn.clicked.connect(self.signin) self.ui.SignUp_btn.clicked.connect(self.signup) self.error_dialog = QtWidgets.QMessageBox() self.error_dialog.setWindowTitle("Error") self.error_dialog.setStandardButtons(QMessageBox.Ok) self.info_dialog = QtWidgets.QMessageBox() self.info_dialog.setWindowTitle('INFO') self.info_dialog.setStandardButtons(QMessageBox.Ok)
def cddvd(self): self.disk_dest = "" from cddvdui import Ui_MainWindow self.hide() QtGui.QWidget.__init__(self, None) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.show() QtCore.QObject.connect(self.ui.Btn_Back, QtCore.SIGNAL("clicked()"), self.backtomain) QtCore.QObject.connect(self.ui.selectDVDButton, QtCore.SIGNAL("clicked()"), self.select_dvd) QtCore.QObject.connect(self.ui.selectUSBButton, QtCore.SIGNAL("clicked()"), self.select_disk) QtCore.QObject.connect(self.ui.Btn_cddvdStart, QtCore.SIGNAL("clicked()"), self.createfromdvd) QtCore.QObject.connect(self.ui.Btn_download, QtCore.SIGNAL("clicked()"), self.downloaddist)
def backtomain(self): from mainui import Ui_MainWindow self.hide() QtGui.QWidget.__init__(self, None) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.show() QtCore.QObject.connect(self.ui.Btn_cddvd, QtCore.SIGNAL("clicked()"), self.cddvd) QtCore.QObject.connect(self.ui.Btn_isoimg, QtCore.SIGNAL("clicked()"), self.isoimg) QtCore.QObject.connect(self.ui.Btn_format, QtCore.SIGNAL("clicked()"), self.formatpage) QtCore.QObject.connect(self.ui.Btn_download, QtCore.SIGNAL("clicked()"), self.downloaddist) self.selected = "" self.img_src = "" self.disk_dest = ""
def fin(self): from completedui import Ui_MainWindow self.hide() QtGui.QWidget.__init__(self, None) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.show() if unicode(self.selected) != unicode(sourceimg): shutil.move(tempfile.gettempdir() + "\\temp.iso", unicode(self.selected)) try: isoname = unicode(self.selected).split("/")[-1].encode( 'ascii', 'ignore') webbrowser.open( "http://www.oguzkirat.com/apps/usbtransfer/completed.php?ver=" + str(version) + "&os=" + urllib.pathname2url(isoname)) except: pass
class UIPracticeWindow(QtWidgets.QMainWindow): def __init__(self, parent=None): super(UIPracticeWindow, self).__init__(parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) # User functions self.ui.pushButton.clicked.connect(self.printDennts) self.ui.clear.clicked.connect(self.cleartext) self.ui.pushButton.clicked.connect(self.printMessage) def printDennts(self): self.ui.textEdit.setText(" Dennts") def cleartext(self): self.ui.textEdit.setText("") def printMessage(self): print("Hello World")
def __init__(self, MainWindow): super(MyApp, self).__init__() # uic.loadUi(qtCreatorFile, self) tmp = "" dimension = None bit_rate = 8000 # default Ui_MainWindow.__init__(self) self.setupUi(MainWindow) # self.setupUi(self) # self.menuAbout.itemPressed.connect(self.menu_about) # check if process Scrcpy is running right now in while loop if checkProcessRunning("scrcpy"): print("SCRCPY RUNNING") self.runningNot.setText("SCRCPY SERVER RUNNING") else: print("SCRCPY SERVER IS INACTIVE") self.runningNot.setText("SCRCPY SERVER NOT RUNNING") # CONNECT DIMENSION CHECK BOX TO STATE CHANGE self.dimensionDefaultCheckbox.stateChanged.connect( self.dimensionChange) self.build_label.setText("Build " + str(build)) # DIAL CTRL GRP self.dial.sliderMoved.connect(self.dial_text_refresh) self.dial.sliderReleased.connect(self.dial_text_refresh) # DIAL CTRL GRP # MAIN EXECUTE ACTION self.executeaction.clicked.connect(self.start_act) self.quit.clicked.connect(self.quitAct) self.dimensionText.setText("DEFAULT") bit_rate = int(self.dial.value()) self.bitrateText.setText(str(bit_rate) + "KB/s")
class ControlMainWindow(QtGui.QMainWindow): up_camera_signal = QtCore.Signal(io.BytesIO) def __init__(self, parent=None): super(ControlMainWindow, self).__init__(parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.up_camera_signal.connect(self.updateImage) def updateImage(self, data): image = Image.open(data) raw_data = str(image.convert("RGBA").tobytes("raw", "RGBA")) qim = QtGui.QImage(raw_data, image.size[0], image.size[1], QtGui.QImage.Format_ARGB32) self.ui.cameraOneLabel.setPixmap(QtGui.QPixmap.fromImage(qim)) self.ui.cameraOneLabel.adjustSize() def setImage(self, data): data = io.BytesIO(data) self.up_camera_signal.emit(data)
def createfromimage(self): try: str(self.selected) self.img_src = self.selected except: self.onay = QtGui.QMessageBox.question( self, self.tr('Warning'), self. tr("Selected file's path is containing special characters. To prevent problems, USBTransfer will move it to temporary directory and move it back. Click Yes if you want to move the file to temporary directory or click No to cancel the operation and change the path yourself.\nWhile moving program may seem unresponsive." ), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) if self.onay == QtGui.QMessageBox.Yes: shutil.move(unicode(self.selected), tempfile.gettempdir() + "\\temp.iso") self.img_src = tempfile.gettempdir() + "\\temp.iso" else: self.img_src = "" if unicode(self.img_src) != "" and self.disk_dest != "": self.img_size = os.stat(self.img_src).st_size if osystem == 'win32': self.disk_size = int(self.driveliste[int(self.disk_dest)][4]) elif osystem == 'linux2': self.disk_size = (int(self.a.drives[self.disk_dest]['size']) * (1024 * 1024)) global sourceimg sourceimg = self.img_src global targetdisk targetdisk = self.disk_dest global size size = self.img_size / (1024**2) if self.img_size > self.disk_size: req_size = ((self.img_size - self.disk_size) / mbyte) self.warning_dialog( self.tr("Error!"), self.tr("There is no enough space on the target disk!") + "\n" + str(req_size) + self.tr("MBs more needed.")) else: self.onay = QtGui.QMessageBox.question( self, self.tr('Warning'), self. tr("You will lose all the data in the disk. Do you want to continue?" ), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) if self.onay == QtGui.QMessageBox.Yes: from progressui import Ui_MainWindow self.hide() QtGui.QWidget.__init__(self, None) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.show() if osystem == "win32": self.preparewin(targetdisk) self.ui.thread = CopyProgress() self.ui.thread.partDone.connect(self.updatePBar) self.ui.thread.procDone.connect(self.fin) self.ui.thread.start() else: self.warning_dialog(self.tr("Canceled"), self.tr("Transfer canceled!")) else: self.warning_dialog( self.tr("Cannot continue."), self.tr("ISO image or target disk wasn't selected!")) return True
class Start(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.img_src = "" self.disk_dest = "" def warning_dialog(self, title, text): QtGui.QMessageBox.warning(self, title, text, QtGui.QMessageBox.Ok) def open_file(self): self.selected = QtGui.QFileDialog.getOpenFileName( self, self.tr("Select an ISO or IMG file")) if string.lower(unicode( self.selected)).endswith('.iso') or string.lower( unicode(self.selected)).endswith('.img'): self.img_src = self.selected elif unicode(self.selected) == "": self.warning_dialog(self.tr("Error!"), self.tr("You didn't selected a file.")) self.img_src = "" else: self.warning_dialog( self.tr("Error!"), self.tr("Selected file is not a ISO or IMG file")) self.img_src = "" def listdiskchange(self, checked=True): if checked: self.sd.listWidget.clear() if osystem == "win32": self.driveliste = {} c = wmi.WMI() if self.sd.r_alldevices.isChecked() == True: for pm in c.Win32_DiskDrive(): self.driveliste[pm.index] = [ "Disk " + str(pm.index) + ":" + str(pm.Model), pm.Model, pm.Name, pm.Partitions, pm.Size, pm.DeviceID, pm.index, pm.InterfaceType, pm.MediaType ] for a in self.driveliste: self.sd.listWidget.insertItem(0, self.driveliste[a][0]) if self.sd.r_onlyusb.isChecked() == True: for pm in c.Win32_DiskDrive(): if pm.InterfaceType == u"USB": self.driveliste[pm.index] = [ "Disk " + str(pm.index) + ":" + str(pm.Model), pm.Model, pm.Name, pm.Partitions, pm.Size, pm.DeviceID, pm.index, pm.InterfaceType, pm.MediaType ] for a in self.driveliste: self.sd.listWidget.insertItem(0, self.driveliste[a][0]) if self.sd.r_onlyremovable.isChecked() == True: for pm in c.Win32_DiskDrive(): if ucwords(str( pm.MediaType)).startswith("Removable Media"): self.driveliste[pm.index] = [ "Disk " + str(pm.index) + ":" + str(pm.Model), pm.Model, pm.Name, pm.Partitions, pm.Size, pm.DeviceID, pm.index, pm.InterfaceType, pm.MediaType ] for a in self.driveliste: self.sd.listWidget.insertItem(0, self.driveliste[a][0]) else: self.a = PartitionUtils() self.a.detect_removable_drives() for key in self.a.drives: self.sd.listWidget.insertItem(0, key) def listdvdchange(self): self.sd.listWidget.clear() if osystem == "win32": self.b = win32_PartitionUtils() self.b.win32_detect_dvd_drives() for key in self.b.drives: self.sd.listWidget.insertItem(0, key) def select_disk(self): self.temp_disk_dest = "" self.disk_dest = "" self.sd = selectDisk() if osystem == "win32": self.listdiskchange(True) self.connect(self.sd.r_onlyremovable, QtCore.SIGNAL("toggled(bool)"), self.listdiskchange) self.connect(self.sd.r_alldevices, QtCore.SIGNAL("toggled(bool)"), self.listdiskchange) self.connect(self.sd.r_onlyusb, QtCore.SIGNAL("toggled(bool)"), self.listdiskchange) elif osystem == 'linux2': self.a = PartitionUtils() self.a.detect_removable_drives() for key in self.a.drives: self.sd.listWidget.insertItem(0, key) self.sd.r_onlyremovable.hide() self.sd.r_onlyusb.hide() self.sd.r_alldevices.hide() self.connect(self.sd.listWidget, QtCore.SIGNAL("itemClicked(QListWidgetItem *)"), self.get_disk_destination) self.connect(self.sd.pushButton, QtCore.SIGNAL("clicked()"), self.listdiskchange) self.connect(self.sd.buttonBox, QtCore.SIGNAL("accepted()"), self.set_disk_destination) self.sd.exec_() QtCore.pyqtSignature("bool") def select_dvd(self): self.sd = selectDisk() if osystem == "win32": self.b = win32_PartitionUtils() self.b.win32_detect_dvd_drives() for key in self.b.drives: self.sd.listWidget.insertItem(0, key) elif osystem == "linux2": self.b = PartitionUtils() self.b.detect_dvd_drives() for key in self.b.drives: self.sd.listWidget.insertItem(0, key) self.sd.r_onlyremovable.hide() self.sd.r_onlyusb.hide() self.sd.r_alldevices.hide() self.connect(self.sd.pushButton, QtCore.SIGNAL("clicked()"), self.listdvdchange) self.connect(self.sd.listWidget, QtCore.SIGNAL("itemClicked(QListWidgetItem *)"), self.get_dvd_destination) self.connect(self.sd.buttonBox, QtCore.SIGNAL("accepted()"), self.set_dvd_destination) self.sd.exec_() QtCore.pyqtSignature("bool") def get_disk_destination(self, item): if item.text(): if osystem == 'win32': self.temp_disk_dest = str(item.text()).split(":")[0][5:] else: self.temp_disk_dest = str(item.text()) print self.temp_disk_dest else: print "No text" def set_disk_destination(self): self.disk_dest = self.temp_disk_dest def get_dvd_destination(self, item): if item.text(): self.tmp_img_src = str(item.text()) print self.tmp_img_src def set_dvd_destination(self): self.img_src = self.tmp_img_src print self.img_src def updatePBar(self, val): self.ui.progressBar.setValue(val) perct = "{0}%".format(val) self.ui.label.setText( "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n" "<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt; font-weight:600;\">" + perct + '</span></p></body></html>') self.ui.label_2.setText( "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n" "<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">" + self.tr("Transfered:") + str((val * size) / 100) + " MB</span></p></body></html>") self.ui.label_3.setText( "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n" "<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">" + self.tr("Total:") + str(size) + " MB</span></p></body></html>") self.ui.label_4.setText( "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n" "<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">" + self.tr("Remaining:") + str(size - ((val * size) / 100)) + " MB</span></p></body></html>") def preparewin(self, targetdisk): if platform.win32_ver()[0] == "XP": c = wmi.WMI() for physical_disk in c.Win32_DiskDrive(): for partition in physical_disk.associators( "Win32_DiskDriveToDiskPartition"): for logical_disk in partition.associators( "Win32_LogicalDiskToPartition"): if int(physical_disk.Index) == int(self.disk_dest): cmda = "Echo E | format " + logical_disk.Caption + " /q /fs:FAT32" os.popen(cmda) else: partitions = self.driveliste[int(targetdisk)][3] f = open("dps.txt", 'w') f.write("select disk " + str(targetdisk) + "\r\nclean\r\ncreate partition primary\r\nexit") f.close() os.popen("diskpart.exe /s dps.txt") os.remove("dps.txt") p = subprocess.Popen('dd.exe --list', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) output, errors = p.communicate() b = errors.split("\r\n") for x in b: if x.count("\\\\?\\Device\\Harddisk" + targetdisk + "\\DR") > 0: global finaltarget finaltarget = x.replace(" ", "").replace("linkto", "") c = wmi.WMI() for pm in c.Win32_PerfRawData_PerfDisk_PhysicalDisk(): if pm.Name != u"_Total": a = pm.Name b = a.split(" ") if int(b[0]) == int(self.disk_dest): c = b[1] global finalvolumetarget finalvolumetarget = "\\\\.\\" + c def fin(self): from completedui import Ui_MainWindow self.hide() QtGui.QWidget.__init__(self, None) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.show() if unicode(self.selected) != unicode(sourceimg): shutil.move(tempfile.gettempdir() + "\\temp.iso", unicode(self.selected)) try: isoname = unicode(self.selected).split("/")[-1].encode( 'ascii', 'ignore') webbrowser.open( "http://www.oguzkirat.com/apps/usbtransfer/completed.php?ver=" + str(version) + "&os=" + urllib.pathname2url(isoname)) except: pass def createfromimage(self): try: str(self.selected) self.img_src = self.selected except: self.onay = QtGui.QMessageBox.question( self, self.tr('Warning'), self. tr("Selected file's path is containing special characters. To prevent problems, USBTransfer will move it to temporary directory and move it back. Click Yes if you want to move the file to temporary directory or click No to cancel the operation and change the path yourself.\nWhile moving program may seem unresponsive." ), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) if self.onay == QtGui.QMessageBox.Yes: shutil.move(unicode(self.selected), tempfile.gettempdir() + "\\temp.iso") self.img_src = tempfile.gettempdir() + "\\temp.iso" else: self.img_src = "" if unicode(self.img_src) != "" and self.disk_dest != "": self.img_size = os.stat(self.img_src).st_size if osystem == 'win32': self.disk_size = int(self.driveliste[int(self.disk_dest)][4]) elif osystem == 'linux2': self.disk_size = (int(self.a.drives[self.disk_dest]['size']) * (1024 * 1024)) global sourceimg sourceimg = self.img_src global targetdisk targetdisk = self.disk_dest global size size = self.img_size / (1024**2) if self.img_size > self.disk_size: req_size = ((self.img_size - self.disk_size) / mbyte) self.warning_dialog( self.tr("Error!"), self.tr("There is no enough space on the target disk!") + "\n" + str(req_size) + self.tr("MBs more needed.")) else: self.onay = QtGui.QMessageBox.question( self, self.tr('Warning'), self. tr("You will lose all the data in the disk. Do you want to continue?" ), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) if self.onay == QtGui.QMessageBox.Yes: from progressui import Ui_MainWindow self.hide() QtGui.QWidget.__init__(self, None) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.show() if osystem == "win32": self.preparewin(targetdisk) self.ui.thread = CopyProgress() self.ui.thread.partDone.connect(self.updatePBar) self.ui.thread.procDone.connect(self.fin) self.ui.thread.start() else: self.warning_dialog(self.tr("Canceled"), self.tr("Transfer canceled!")) else: self.warning_dialog( self.tr("Cannot continue."), self.tr("ISO image or target disk wasn't selected!")) return True def createfromdvd(self): if self.img_src != "" and self.disk_dest != "": if osystem == 'win32': self.disk_size = int(self.driveliste[int(self.disk_dest)][4]) self.img_size = (int(self.b.drives[self.img_src]['size']) * (1024 * 1024)) elif osystem == 'linux2': self.disk_size = (int(self.a.drives[self.disk_dest]['size'])) self.img_size = (int(self.b.drives[self.img_src]['size'])) if osystem == "win32": simg = "\\\\.\\" + self.img_src else: simg = self.img_src global sourceimg sourceimg = simg global targetdisk targetdisk = self.disk_dest global size size = self.img_size / (1024**2) if self.img_size > self.disk_size: req_size = ((self.img_size - self.disk_size) / mbyte) self.warning_dialog( self.tr("Error!"), self.tr("There is no enough space on the target disk!") + "\n" + str(req_size) + self.tr("MBs more needed.")) else: self.onay = QtGui.QMessageBox.question( self, self.tr('Warning'), self. tr("You will lose all the data in the disk. Do you want to continue?" ), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) if self.onay == QtGui.QMessageBox.Yes: from progressui import Ui_MainWindow self.hide() QtGui.QWidget.__init__(self, None) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.show() if osystem == "win32": self.preparewin(targetdisk) self.ui.thread = CopyProgress() self.ui.thread.partDone.connect(self.updatePBar) self.ui.thread.procDone.connect(self.fin) self.ui.thread.start() else: self.warning_dialog(self.tr("Canceled!"), self.tr("Transfer canceled!")) else: self.warning_dialog( self.tr("Cannot continue."), self.tr("CD/DVD drive or target disk wasn't selected!")) return True @QtCore.pyqtSignature("bool") def formatting(self): if self.disk_dest != "": self.onay = QtGui.QMessageBox.question( self, self.tr('Warning'), self. tr("You will lose all the data in the disk. Do you want to continue?" ), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) if self.onay == QtGui.QMessageBox.Yes: if osystem == "win32": os.popen(str('taskkill /f /im dd.exe')) if platform.win32_ver()[0] == "XP": print "It is Windows XP" self.preparewin(self.disk_dest) cmda = 'dd.exe if=/dev/zero of=' + finaltarget + ' bs=512 count=1 --progress' ##dd command print cmda os.popen(cmda) c = wmi.WMI() for physical_disk in c.Win32_DiskDrive(): for partition in physical_disk.associators( "Win32_DiskDriveToDiskPartition"): for logical_disk in partition.associators( "Win32_LogicalDiskToPartition"): if int(physical_disk.Index) == int( self.disk_dest): print logical_disk.Caption cmda = "Echo E | format " + logical_disk.Caption + " /q /fs:FAT32" print cmda os.popen(cmda) else: f = open("dps.txt", 'w') f.write("select disk " + str(self.disk_dest) + "\r\n") f.write( "clean\r\ncreate partition primary\n\rformat fs=FAT32 QUICK OVERRIDE\n\rexit" ) f.close() os.popen("diskpart.exe /s dps.txt") os.remove("dps.txt") self.warning_dialog( self.tr("Format Completed"), self. tr("Format completed, if it didn't work, try another format and partitioning tool to use your device." )) else: f = open("dps.txt", 'w') f.write("fdisk " + self.disk_dest + " << EOF\no\nn\np\n\n\n\nw\nEOF\numount " + self.disk_dest + "1\nmkfs -t vfat " + self.disk_dest + "1") f.close() os.system("chmod +x dps.txt") os.system("./dps.txt") self.warning_dialog( self.tr("Format Completed"), self. tr("You might need to restart your computer to use your device again." )) self.disk_dest = "" else: self.warning_dialog(self.tr("Cannot continue."), self.tr("Target disk wasn't selected!")) def backtomain(self): from mainui import Ui_MainWindow self.hide() QtGui.QWidget.__init__(self, None) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.show() QtCore.QObject.connect(self.ui.Btn_cddvd, QtCore.SIGNAL("clicked()"), self.cddvd) QtCore.QObject.connect(self.ui.Btn_isoimg, QtCore.SIGNAL("clicked()"), self.isoimg) QtCore.QObject.connect(self.ui.Btn_format, QtCore.SIGNAL("clicked()"), self.formatpage) QtCore.QObject.connect(self.ui.Btn_download, QtCore.SIGNAL("clicked()"), self.downloaddist) self.selected = "" self.img_src = "" self.disk_dest = "" def cddvd(self): self.disk_dest = "" from cddvdui import Ui_MainWindow self.hide() QtGui.QWidget.__init__(self, None) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.show() QtCore.QObject.connect(self.ui.Btn_Back, QtCore.SIGNAL("clicked()"), self.backtomain) QtCore.QObject.connect(self.ui.selectDVDButton, QtCore.SIGNAL("clicked()"), self.select_dvd) QtCore.QObject.connect(self.ui.selectUSBButton, QtCore.SIGNAL("clicked()"), self.select_disk) QtCore.QObject.connect(self.ui.Btn_cddvdStart, QtCore.SIGNAL("clicked()"), self.createfromdvd) QtCore.QObject.connect(self.ui.Btn_download, QtCore.SIGNAL("clicked()"), self.downloaddist) def isoimg(self): self.disk_dest = "" from isoimgui import Ui_MainWindow self.hide() QtGui.QWidget.__init__(self, None) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.show() QtCore.QObject.connect(self.ui.Btn_Back, QtCore.SIGNAL("clicked()"), self.backtomain) QtCore.QObject.connect(self.ui.Btn_download, QtCore.SIGNAL("clicked()"), self.downloaddist) QtCore.QObject.connect(self.ui.selectfileBtn, QtCore.SIGNAL("clicked()"), self.open_file) QtCore.QObject.connect(self.ui.selectUSBButton, QtCore.SIGNAL("clicked()"), self.select_disk) QtCore.QObject.connect(self.ui.Btn_cddvdStart, QtCore.SIGNAL("clicked()"), self.createfromimage) def formatpage(self): self.disk_dest = "" from formatuiwin import Ui_MainWindow self.hide() QtGui.QWidget.__init__(self, None) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.show() QtCore.QObject.connect(self.ui.selectUSBButton, QtCore.SIGNAL("clicked()"), self.select_disk) QtCore.QObject.connect(self.ui.Btn_Back, QtCore.SIGNAL("clicked()"), self.backtomain) QtCore.QObject.connect(self.ui.Btn_formatStart, QtCore.SIGNAL("clicked()"), self.formatting) def webhelp(self): webbrowser.open("http://www.oguzkirat.com/usb-transfer-help") def translate(self): webbrowser.open("http://www.oguzkirat.com/usb-transfer-translations") def webupdate(self): try: con = urllib.urlopen( "http://usbaktarici.googlecode.com/svn/trunk/version") data = con.read() con.close() if int(data) > 301: self.onay = QtGui.QMessageBox.question( self, _fromUtf8('Warning'), _fromUtf8( "New version is available, do you want to download?"), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) if self.onay == QtGui.QMessageBox.Yes: webbrowser.open("http://www.oguzkirat.com/usb-transfer") else: self.warning_dialog( self.tr("Warning"), self.tr("You are using the latest version.")) except: self.warning_dialog( self.tr("Error"), self.tr("Couldn't connect to project web site.")) def about(self): QtGui.QMessageBox.about( self, self.tr("About"), _fromUtf8( "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n" "<p><strong>USBTransfer</strong><br />Version: 3.0.1</p><p>Developed and designed by:<br />Oğuz Kırat<br />http://www.oguzkirat.com</p><strong>Translations</strong><br /><strong>Arabic: </strong>Circoficus & zeugma<br /><strong>Dutch: </strong>Pjotr<br /><strong>Estonian: </strong>Rivo Zängov<br /><strong>German: </strong>Claas<br /><strong>Italian: </strong>Hüdaverdi Sarıaltın<br /><strong>Portuguese: </strong>Felipe Fzero<br /><strong>Russian: </strong>Alexey Ivanov<br /><strong>Spanish: </strong>Deicidium<p>©2011 Oğuz Kırat<br/>This program is distributed under the terms of the GNU General Public License as published by the Free Software Foundation.</body></html>" )) def languageselector(self, parent=None): QtGui.QWidget.__init__(self, None) from langselectui import Ui_MainWindow self.ui = Ui_MainWindow() self.ui.setupUi(self) self.show() QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.loadlanguage) clickable(self.ui.help).connect(self.webhelp) clickable(self.ui.checkupdatesBtn).connect(self.webupdate) clickable(self.ui.aboutBtn).connect(self.about) clickable(self.ui.translatenow).connect(self.translate) try: con = urllib.urlopen( "http://usbaktarici.googlecode.com/svn/trunk/version") data = con.read() con.close() if int(data) > version: self.onay = QtGui.QMessageBox.question( self, _fromUtf8('Warning'), _fromUtf8( "New version is available, do you want to download?"), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) if self.onay == QtGui.QMessageBox.Yes: webbrowser.open("http://www.oguzkirat.com/usb-transfer") except: pass def downloaddist(self): webbrowser.open("http://www.oguzkirat.com/linux-distributions") def loadlanguage(self): self.selectedlanguage = self.ui.langBox.currentText() print self.selectedlanguage if self.selectedlanguage != "English": translator = QtCore.QTranslator(app) translator.load("lang/" + self.selectedlanguage + ".qm") app.installTranslator(translator) if osystem == "win32": self.backtomain() else: self.backtomain()
head = ['Special Build Description', 'mean', 'median', 'std'] self.item_mean_std.setColumnCount(column) self.item_mean_std.setRowCount(row) self.item_mean_std.setHorizontalHeaderLabels(head) for i in range(0,row): for j in range(0, column): self.item_mean_std.setItem(i, j, QTableWidgetItem(str(temp_data.values[i][j]))) def hello(self): self.file_path.setText("hello world!") print("hello world") self.update_item_mean_std() app = QtWidgets.QApplication(sys.argv) #MainWindow = QMainWindow() window = Ui_MainWindow() window.show() sys.exit(app.exec_()) class mywindow(QtWidgets.QMainWindow, Ui_MainWindow): def __init__(self): super(mywindow, self).__init__() self.setupUi(self) def update_item_mean_std(self, temp_data, column, row): head = ['Special Build Description', 'mean', 'median', 'std'] self.item_mean_std.setColumnCount(column) self.item_mean_std.setRowCount(row) self.item_mean_std.setHorizontalHeaderLabels(head)
class MyApp(QtWidgets.QMainWindow): def __init__(self): super(MyApp, self).__init__() self.logfile = '' self.ui = Ui_MainWindow() self.ui.setupUi(self) # self.ui.setupUiExt(self) # self.ui.setupWidget(self) self.initialize() self._setup_signal() self.drvlog = None self.activesensor = 'accelerometer' def initialize(self): try: self.ui.select_file_button.hide() self.ui.analyze_button.setDisabled(True) except FileNotFoundError as e: warning_dialog("Warning", "{}: {}".format(e.strerror, e.filename)) def _setup_signal(self): self.ui.select_file_button.clicked.connect(self.choose_log_file) self.ui.action_load_logfile.triggered.connect(self.choose_log_file) self.ui.analyze_button.clicked.connect(self.show_fft_result) # self.ui.analyze_button.clicked.connect(self.show_fft_result) def choose_log_file(self): self.logfile, _ = QtWidgets.QFileDialog.getOpenFileName( self, "select file", os.path.dirname(__file__), "Text Files (*.log)") if self.logfile: self.ui.label.setText(self.logfile) self.drvlog = DrvLog(self.logfile) self.drvlog.parse_acc_data() self.drvlog.parse_gyr_data() self.set_table_data(self.drvlog.df_dict['accelerometer'], self.ui.acc_data_tableView) self.set_table_data(self.drvlog.df_dict['gyroscope'], self.ui.gyr_data_tableView) self.ui.analyze_button.setEnabled(True) else: # warning_dialog("File Not Found", "cannot find selected file") self.ui.analyze_button.setDisabled(True) def set_table_data(self, df, table_widget): model = PandasModel(df) view = table_widget fnt = view.font() fnt.setPointSize(9) view.setFont(fnt) view.setModel(model) view.horizontalHeader().stretchLastSection() view.verticalHeader().stretchLastSection() # view.resizeColumnsToContents() # view.setWindowTitle('viewer') view.show() # self.adjustSize() def show_fft_result(self): if self.ui.tabWidget.currentIndex() == 0: self.activesensor = "accelerometer" elif self.ui.tabWidget.currentIndex() == 1: self.activesensor = "gyroscope" # sample_period = self.drvlog.df_dict[sensor].describe()['timestamp(ms)']['max'] -\ # self.drvlog.df_dict[sensor].describe()['timestamp(ms)']['min'] # sampling period(ms) # sample_period = sample_period / 1000 # # plot_series( plot_result(self.drvlog.df_dict[self.activesensor], sensor=self.activesensor)
def __init__(self, parent=None): super(ControlMainWindow, self).__init__(parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.up_camera_signal.connect(self.updateImage)
def __init__(self, MainWindow): super(MyApp, self).__init__() # uic.loadUi(qtCreatorFile, self) Ui_MainWindow.__init__(self) self.setupUi(MainWindow) # self.setupUi(self) # self.menuAbout.itemPressed.connect(self.menu_about) # check if process Scrcpy is running right now in while loop """ background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(0, 255, 255, 255), stop:1 rgba(0, 255, 152, 255)); color: rgb(0, 0, 0); border-radius: 10px; border-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 255, 255), stop:1 rgba(255, 0, 255, 255)); """ bit_rate = bitrate0 dimensions = dimension0 swtouches = swtouches0 dispRO = dispRO0 fullscreen_opt = fullscreen0 print("OPTS:", bit_rate, dimensions, swtouches, dispRO, fullscreen_opt) self.dial.setValue(int(bit_rate)) if (swtouches.find("True")>-1): self.showTouches.setChecked(True) else: self.showTouches.setChecked(False) if (dispRO.find("True")>-1): self.displayForceOn.setChecked(True) else: self.displayForceOn.setChecked(False) if dimensions != None: self.dimensionDefaultCheckbox.setChecked(False) try: self.dimensionSlider.setValue(dimensions) except TypeError: self.dimensionDefaultCheckbox.setChecked(True) if (fullscreen_opt.find("True")>-1): self.fullscreen.setChecked(True) else: self.fullscreen.setChecked(False) if checkProcessRunning("scrcpy"): print("SCRCPY RUNNING") self.runningNot.setText("SCRCPY SERVER RUNNING") else: print("SCRCPY SERVER IS INACTIVE") self.runningNot.setText("SCRCPY SERVER NOT RUNNING") # CONNECT DIMENSION CHECK BOX TO STATE CHANGE self.dimensionDefaultCheckbox.stateChanged.connect(self.dimensionChange) self.build_label.setText("Build " + str(build)) # DIAL CTRL GRP self.dial.sliderMoved.connect(self.dial_text_refresh) self.dial.sliderReleased.connect(self.dial_text_refresh) # DIAL CTRL GRP # MAIN EXECUTE ACTION self.executeaction.clicked.connect(self.start_act) self.quit.clicked.connect(self.quitAct) self.dimensionText.setText("DEFAULT") bit_rate = int(self.dial.value()) self.bitrateText.setText(" " + str(bit_rate) + "KB/s") self.pushButton.setText("RESET") self.pushButton.clicked.connect(self.reset) self.abtme.clicked.connect(self.openme) self.abtgit.clicked.connect(self.opengit)
class Appwindow(QMainWindow): def __init__(self): super(Appwindow, self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.timer = QTimer() # self.timer.timeout.connect(self.tick) self.timer.timeout.connect(self.UDP_Srver) self.ui.btn_start_udp_server.clicked.connect(self.buttonClicked) self.ui.btn_stop_udp_server.clicked.connect(self.btn_stop) # self.timer.stop() pyqtgraph.setConfigOption('background', 'w') #before loading widget self.t = np.array([0]) self.x = np.array([0]) self.pocket_num = 0 def tick(self): print('tick') def buttonClicked(self): sender = self.sender() self.statusBar().showMessage(sender.text() + ' was pressed') rate = (1 / float(self.ui.in_Rate.text()) * 1000) self.timer.start(rate) print((rate), ' ms delay.') def btn_stop(self): self.timer.stop() plt.plot(self.t, self.x) plt.show() print(self.t, self.x) def UDP_Srver(self): # IP="0.0.0.0" IP = self.ui.in_IP.text() # PORT=50890 PORT = int(self.ui.in_Port.text()) with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as soc: soc.bind((IP, PORT)) data = soc.recv(1024) data = str(data).split(',') if data: self.x = np.append(self.x, data[21]) self.t = np.append(self.t, (self.pocket_num)) self.pocket_num += 1 # self.ui.graphicsView # pyqtgraph.plot(self.t,self.x) self.ui.treeWidget.setHeaderLabels(["A", "B"]) Item_label = [ 'Time', 'DataGram#', '', 'Device', '', 'Latitude', 'Longtitude', 'Altitude', 'speed', 'course', 'Vertical acc', 'Horizontal acc', '?1', '?2', 'MicroTesl-X', 'MicroTesl-Y', 'MicroTesl-Z', 'True north', 'Magnet north', 'Accuracy', '??', 'Pitch', 'Roll', 'Yaw', '??', 'Rote-rate-X', 'Rote-rate-Y', 'Rote-rate-Z' ] self.ui.treeWidget.clear() for cnt, i in enumerate(data): Item1 = QTreeWidgetItem() Item2 = QTreeWidgetItem() Item1.setText(1, str(i)) Item1.setText(0, str(cnt)) if (len(Item_label) > cnt): Item1.setText(0, str(cnt) + '- ' + Item_label[int(cnt)]) self.ui.treeWidget.addTopLevelItem(Item1)