def save(self): save_file = QFile(self.filename) result = save_file.open(QFile.WriteOnly) if result: save_stream = QTextStream(save_file) save_stream << self.text() save_file.close()
def save(self): self.filename = str(STATUS.file) save_file = QFile(self.filename) result = save_file.open(QFile.WriteOnly) if result: save_stream = QTextStream(save_file) save_stream << self.text() save_file.close() else: print("save error")
def save(self): save_file = QFile(self.filename) result = save_file.open(QFile.WriteOnly) if result: LOG.debug("---self.text(): {}".format(self.text())) save_stream = QTextStream(save_file) save_stream << self.text() save_file.close() self.text_before_edit = '' self.somethingHasChanged.emit(False) else: LOG.debug("---save error")
def saveFile(self, save_file_name=None): if save_file_name == None: save_file = QFile(str(STATUS.file)) else: save_file = QFile(str(save_file_name)) result = save_file.open(QFile.WriteOnly) if result: LOG.debug(f'---Save file: {save_file.fileName()}') save_stream = QTextStream(save_file) save_stream << self.toPlainText() save_file.close() else: LOG.debug("---save error")
def updateFrameSheet(self): if globals.applied_style == 'light': f = QFile(':/frameless-light.qss') elif globals.applied_style == 'dark': f = QFile(':/frameless-dark.qss') else: raise RuntimeError( 'Set the app style theme before instantiating ModernWindow') f.open(QIODevice.ReadOnly | QIODevice.Text) text = QTextStream(f) text.setCodec('UTF-8') text = text.readAll() self.setStyleSheet(text) f.close()
def saveAs(self): file_name = self.save_as_dialog(self.filename) if file_name is False: return original_file = QFileInfo(self.filename) path = original_file.path() new_absolute_path = os.path.join(path, file_name) new_file = QFile(new_absolute_path) result = new_file.open(QFile.WriteOnly) if result: save_stream = QTextStream(new_file) save_stream << self.text() new_file.close()
def _apply_base_theme(app): """ Apply base theme to the application. Args: app (QApplication): QApplication instance. """ if QT_VERSION < (5,): app.setStyle('plastique') else: app.setStyle('Fusion') f = QFile(':/style.qss') f.open(QIODevice.ReadOnly | QIODevice.Text) text = QTextStream(f) text.setCodec('UTF-8') app.setStyleSheet(text.readAll()) f.close()
def tofile(self, path): """Write the bloom filter to file object `f'. Underlying bits are written as machine values. This is much more space efficient than pickling the object.""" # f.write(pack(self.FILE_FMT, self.error_rate, self.num_slices, # self.bits_per_slice, self.capacity, self.count)) # f.write(self.bitarray.bits) f = QFile(path) if f.open(QIODevice.WriteOnly): out = QDataStream(f) out.writeBytes(self.FILE_FMT) out.writeFloat(self.error_rate) out.writeInt(self.num_slices) out.writeInt(self.bits_per_slice) out.writeInt(self.capacity) out.writeInt(self.count) out << self.bitarray f.flush() f.close()
def saveAs(self): file_name = self.save_as_dialog(self.filename) if file_name is False: print("saveAs file name error") return self.filename = str(STATUS.file) original_file = QFileInfo(self.filename) path = original_file.path() new_absolute_path = os.path.join(path, file_name) new_file = QFile(new_absolute_path) result = new_file.open(QFile.WriteOnly) if result: save_stream = QTextStream(new_file) save_stream << self.text() new_file.close() self.text_before_edit = '' self.somethingHasChanged.emit(False)
def saveAs(self): #file_name = self.save_as_dialog(self.filename) options = QFileDialog.Options() options |= QFileDialog.DontUseNativeDialog file_name, _ = QFileDialog.getSaveFileName(self,"Save As","","All Files (*);;NGC Files (*.ngc)", options=options) if file_name is False: print("saveAs file name error") return self.filename = str(STATUS.file) original_file = QFileInfo(self.filename) path = original_file.path() new_absolute_path = os.path.join(path, file_name) new_file = QFile(new_absolute_path) result = new_file.open(QFile.WriteOnly) if result: save_stream = QTextStream(new_file) save_stream << self.text() new_file.close()
def main(): app = QApplication(sys.argv) app.setWindowIcon(QIcon(':/icons/app.svg')) fontDB = QFontDatabase() fontDB.addApplicationFont(':/fonts/Roboto-Regular.ttf') app.setFont(QFont('Roboto')) f = QFile(':/style.qss') f.open(QFile.ReadOnly | QFile.Text) app.setStyleSheet(QTextStream(f).readAll()) f.close() translator = QTranslator() translator.load(':/translations/' + QLocale.system().name() + '.qm') app.installTranslator(translator) mw = MainWindow() mw.show() sys.exit(app.exec_())
def save(self): reload_file = True self.filename = str(STATUS.file) # determine of have a file name if self.filename == '': reload_file = False self.filename = '/tmp/gcode_tmp.ngc' # save out the file save_file = QFile(self.filename) result = save_file.open(QFile.WriteOnly) if result: save_stream = QTextStream(save_file) save_stream << self.text() save_file.close() # file save worked, now either load fresh or reload if reload_file: reLoadProgram() else: loadProgram(self.filename) else: print("save error")