def fileNew(self): if not self.okToContinue(): return dialog = newimagedlg.NewImageDlg(self) if dialog.exec_(): self.addRecentFile(self.filename) self.image = QImage() for action, check in self.resetableActions: action.setChecked(check) self.image = dialog.image() self.filename = None self.dirty = True self.showImage() self.sizeLabel.setText("{0} x {1}".format(self.image.width(), self.image.height())) self.updateStatus("Created new image")
def fileNew(self): if not self.okToContinue(): #判断当前任务是否完成,提示进行保存或重新加载 return dialog = newimagedlg.NewImageDlg(self) if dialog.exec_(): try: self.addRecentFile(self.filename) # 将上一个图像添加到recentFile中 self.image = QImage() #对一些关键变量进行初始化(__init__内部的) for action, check in self.resetableActions: action.setChecked(check) #对action进行初始化 self.image = dialog.image() #把生成的图像赋值给images属性 self.filename = None self.dirty = True # self.showImage() #展示图片,然后设置通知栏的提示和Log提示 try: self.showImage() except: self.showbug() self.sizeLabel.setText( "%s × %s" % (self.image.width(), self.image.height())) self.updateStatus("创建一个新图像") except: self.showbug()