我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用tkMessageBox.showwarning()。
def _UpdateFirmwareCmd(self): q = tkMessageBox.showwarning('Update Fimware','Warning! Interrupting firmare update may lead to non functional PiJuice HAT.', parent=self.frame) if q: print 'Updating fimware' inputFile = '/usr/share/pijuice/data/firmware/PiJuice.elf.binary' curAdr = pijuice.config.interface.GetAddress() if curAdr: adr = format(curAdr, 'x') ret = 256 - subprocess.call(['pijuiceboot', adr, inputFile])#subprocess.call([os.getcwd() + '/stmboot', adr, inputFile]) print 'firm res', ret if ret == 256: tkMessageBox.showinfo('Firmware update', 'Finished succesfully!', parent=self.frame) else: errorStatus = self.firmUpdateErrors[ret] if ret < 11 else ' UNKNOWN' msg = '' if errorStatus == 'I2C_BUS_ACCESS_ERROR': msg = 'Check if I2C bus is enabled.' elif errorStatus == 'INPUT_FILE_OPEN_ERROR': msg = 'Firmware binary file might be missing or damaged.' elif errorStatus == 'STARTING_BOOTLOADER_ERROR': msg = 'Try to start bootloader manualy. Press and hold button SW3 while powering up RPI and PiJuice.' tkMessageBox.showerror('Firmware update failed', 'Reason: ' + errorStatus + '. ' + msg, parent=self.frame) else: tkMessageBox.showerror('Firmware update', 'Unknown pijuice I2C address', parent=self.frame)
def show_popup_message(self, popup_type="warning", title_to_show="ALLERT", message_to_show="THIS IS AN ALLERT MESSAGE", parent_window=None, refresh=True): """ Displays error or warning messages and refreshes the sequence window. """ # show_error_message # show_warning_message if parent_window == None: parent_window = self.main_window if popup_type == "error": tkMessageBox.showerror(title_to_show, message_to_show, parent=parent_window) elif popup_type == "info": tkMessageBox.showinfo(title_to_show, message_to_show, parent=parent_window) elif popup_type == "warning": tkMessageBox.showwarning(title_to_show, message_to_show, parent=parent_window) if refresh: self.gridder()
def handleLinearRegression(self): if self.data is None: tkMessageBox.showerror("No Open File", "Please open a file first!") return d = LinearRegressionDialog(self.root, self.data.get_headers()) if d.result is not None: if d.result[0] == "None" or d.result[1] == "None": tkMessageBox.showwarning(title="Incorrect Parameters", message="Option cannot be 'None'") else: self.objects = [] self.linreg_endpoints = None self.linreg_line_objects = [] self.reset() self.updateAxes() self.regression_mode = True self.buildLinearRegression(headers=d.result) # build and display the regression on the plot
def handlePCA(self, event=None): if self.data is None: tkMessageBox.showerror("No File Open", "Please open a file first!") return d = PCADialog(self.root, self.data.get_headers()) if d.result is None: return if d.result[2] in self.pca_data.keys(): tkMessageBox.showwarning("Replacing Saved Analysis", "Please delete old analysis before creating another with the same name.") return if d.result[0] == 1: self.pca_data[d.result[2]] = analysis.pca(self.data, d.result[1]) self.pca_data[d.result[2]].write_to_file(d.result[2], self.pca_data[d.result[2]].get_headers()) print "Normalizing: True" else: self.pca_data[d.result[2]] = analysis.pca(self.data, d.result[1], False) self.pca_data[d.result[2]].write_to_file(d.result[2], self.pca_data[d.result[2]].get_headers()) print "Normalizing: False" if not self.pca_controls_built: self.buildPCAControls() self.pca_lbox.insert(tk.END, d.result[2])
def validate(self): """ Called when the user chooses "OK", before closing the box. Also checks that child name is unique. """ for tk_list in self.frame_dict.values(): if not all(x.validate() for x in tk_list): return False if self.element.parent is not None: if self.element not in self.element.parent.children: if self.name_entry.value.get() in self.element.parent.child_names(): tkMessageBox.showwarning("", "Sibling names must be unique.") return False return True
def new_button_press(self): if self.treeview.focus() == "" and self.root_element is not None: tkMessageBox.showwarning(None, "No parent element selected.") else: if self.treeview.focus() == "" and self.root_element is None: element = CreateRootDialog(self).element if isinstance(element, SeqLib): EditDialog(self, self, element) self.root_element = element else: element = self.create_new_element() EditDialog(self, self, element) # refresh the treeview and re-assign treeview id's self.refresh_treeview() # select the newly added element if it was successfully added if element.treeview_id in self.element_dict.keys(): self.treeview.focus(element.treeview_id) self.treeview.selection_set(element.treeview_id) else: if element.parent is not None: self.treeview.focus(element.parent.treeview_id) self.treeview.selection_set(element.parent.treeview_id) del element
def warningBox(self, title, message): self.topLevel.update_idletasks() MessageBox.showwarning(title, message) self.__bringToFront()
def warning(self, title, message): messagebox.showwarning(title, message)
def validate(self): import tkMessageBox try: result = self.getresult() except ValueError: tkMessageBox.showwarning( "Illegal value", self.errormessage + "\nPlease try again", parent = self ) return 0 if self.minvalue is not None and result < self.minvalue: tkMessageBox.showwarning( "Too small", "The allowed minimum value is %s. " "Please try again." % self.minvalue, parent = self ) return 0 if self.maxvalue is not None and result > self.maxvalue: tkMessageBox.showwarning( "Too large", "The allowed maximum value is %s. " "Please try again." % self.maxvalue, parent = self ) return 0 self.result = result return 1
def callback(self): tkMessageBox.showwarning(title="Not Implemented", message="This feature has not yet been implemented")
def check_NumBeams(LPlan,OTPPlan,passLog,failLog): # Check same number of beams #print LPlan.NumBeams,OTPPlan.NumBeams if not (LPlan.NumBeams == OTPPlan.NumBeams): tkMessageBox.showwarning( "Mismatch", "Plans contain unequal number of beams" ) return False else: return True
def clientConnectionFailed(self, connector, reason): tkMessageBox.showwarning('TkConch','Connection Failed, Reason:\n %s: %s' % (reason.type, reason.value))
def MsgBox(title, text, style): box = [ msg.showinfo, msg.showwarning, msg.showerror, msg.askquestion, msg.askyesno, msg.askokcancel, msg.askretrycancel, ]; tk.Tk().withdraw(); #Hide Main Window. if style in range(7): return box[style](title, text)
def show_warning(self, title, message): return messagebox.showwarning(title, message)
def read_path_from_svg(svg_filename): # re_split = re.compile('\s+|,') try: tree = etree.parse(open(svg_filename)) except (OSError, IOError): tkMessageBox.showwarning(title = 'Error during reticule import',message = "the file %s was not found" %svg_filename) path_list = []; for element in tree.iter(): if element.tag.split("}")[1] == "path": #re_split.split(element.get("d")) path_list.append(element.get('d')) #path_list.append(re_split) Points = string2points(path_list) return Points
def read_colored_path_from_svg(svg_filename): # re_split = re.compile('\s+|,') tree = etree.parse(open(svg_filename)) path_list = {} for element in tree.iter(): if element.tag.split("}")[1] == "path": #re_split.split(element.get("d")) path_color = element.get('style') if type(path_color) == str: ind = path_color.find('fill:') path_color = path_color[(ind+5):(ind+12)] if path_color == '#ff0000': path_color = 'red' elif path_color == '#00ff00': path_color = 'green' elif path_color == '#0000ff': path_color = 'blue' else: tkMessageBox.showwarning('Some colors were not rekognized', 'Only blue, red and green traces are imported') else: path_color = element.get('fill') if path_color not in path_list.keys(): path_list[path_color]=[] path_list[path_color].append(element.get('d')) #path_list.append(re_split) Points = {} for path_color in path_list: Points[path_color] = string2points(path_list[path_color]) return Points
def importSVGroute(IDT_group): IDT_group_dir = IDT_group['IDT_group_dir'] Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing svg_filename = tkFileDialog.askopenfilename(title='Wafer routing filename',defaultextension = 'svg',initialdir = IDT_group_dir); all_points = SVGT.read_colored_path_from_svg(svg_filename) route =[[],[]] for points in all_points['red']: polygon = shapely_geom.Polygon(points.T) polygon_validity = explain_validity(polygon) if polygon_validity=='Valid Geometry': route[0].append(polygon) else: tkMessageBox.showwarning('Error in svg import', polygon_validity) for points in all_points['blue']: polygon = shapely_geom.Polygon(points.T) polygon_validity = explain_validity(polygon) if polygon_validity=='Valid Geometry': route[1].append(polygon) else: tkMessageBox.showwarning('Error in svg import', polygon_validity) route[0] = shapely_geom.MultiPolygon(route[0]) route[1] = shapely_geom.MultiPolygon(route[1]) #outbox = route[0].bounds #dx = outbox[2]-outbox[0] #dy = outbox[3]-outbox[1] #x0 = outbox[0]+dx/2 #y0 = outbox[1]+dy/2 x0 = 4000 y0 = 4000 factor = 1e-5; route[0] = shapely_affinity.translate(route[0], xoff=-x0, yoff=-y0) route[0] = shapely_affinity.scale(route[0], xfact = factor, yfact= factor, origin=(0,0,0)) route[1] = shapely_affinity.translate(route[1], xoff=-x0, yoff=-y0) route[1] = shapely_affinity.scale(route[1], xfact = factor, yfact= factor, origin=(0,0,0)) IDT_group['route'] = route
def checkIPaddr(self,addr): try: socket.inet_pton(socket.AF_INET,addr) return True except socket.error: tkMessageBox.showwarning("Error","Invalid Target IP Address\n(%s)" % addr) return False
def add_new_user_disulfide(self): # Checks that both the comboboxes have been used to select a cys. if (self.list_of_disulfide_combos[-1].cys1_combobox.get() == "" or self.list_of_disulfide_combos[-1].cys2_combobox.get() == ""): txt = "You have to select two cysteines residue to define a disulfide bridge!" tkMessageBox.showwarning("Warning", txt,parent=self.pymod_object.modeling_window) # Checks that the same cys has not been selected in both comboboxes. elif (self.list_of_disulfide_combos[-1].cys1_combobox.get() == self.list_of_disulfide_combos[-1].cys2_combobox.get()): txt = "You cannot select the same cysteine to form a disulfide bridge!" tkMessageBox.showwarning("Message", txt,parent=self.pymod_object.modeling_window) # Checks that the selected cys are not engaged in other bridges. # ... # If the two cys are free to form a bridge, then adds the new bridge and updates the # frame with a new combobox row. else: self.user_disulfides_row_counter += 1 # Adds the new row with comboboxes and an "Add" button. new_ds_combo = User_disulfide_combo( self.pymod_object, self.user_disulfides_row_counter, self.target_list_of_cysteines, self.combobox_frame, self) # Activates the previous row and returns the name of the 2 selected cys. cysteines = self.list_of_disulfide_combos[-1].activate() # Finishes and adds the new row. self.list_of_disulfide_combos.append(new_ds_combo) # Adds the cys pair to the self.user_defined_disulfide_bridges, which is going to be # used in the perform_modelization() method. self.user_defined_disulfide_bridges.append(cysteines) # self.print_user_ds_list() self.pymod_object.disulfides_scrolled_frame.reposition() # This is called when the "Remove" button is pressed.
def handleOpen(self, event=None): fn = tkFileDialog.askopenfilename(parent=self.root, title="Choose a Data file", initialdir='.') if fn.split('.')[1] != "csv" and fn.split('.')[1] != "xls": tkMessageBox.showwarning("Open File", "Cannot open this file\n(%s)" % fn) return self.data = dt.Data(filename=fn) self.handlePlotData() self.filename = fn # allows users to choose which features from the data are to be displayed
def apply(self): try: self.result=[] for i in range(1, len(self.__entries_Func)): r1, r2= self.__entries_Func[i].get(), self.__entries_PinNumb[i].get() if r1 != '' and r2 != '': self.result.append([r1,int(r2)]) #print 'result:', self.result print 'End of dialog' # or something except ValueError: tkMessageBox.showwarning("Bad input","Illegal values, please try again")
def apply(self): try: spd_X = int(self.entry_Speed_X.get()) acc_X = int(self.entry_Acc_X.get()) spd_Y = int(self.entry_Speed_Y.get()) acc_Y = int(self.entry_Acc_Y.get()) spd_Z = int(self.entry_Speed_Z.get()) acc_Z = int(self.entry_Acc_Z.get()) self.result= spd_X, acc_X, spd_Y, acc_Y, spd_Z, acc_Z print spd_X, spd_Y, spd_Z # or something except ValueError: tkMessageBox.showwarning("Bad input","Illegal values, please try again")
def apply(self): try: self.__cameraID = int(self.entry_cameraID.get()) self.result= self.__cameraID print self.result # or something except ValueError: tkMessageBox.showwarning("Bad input","Illegal values, please try again")
def start_clustering(self): try: self.update_status("blue", "PLEASE WAIT. CLUSTERING IN PROGRESS...") infolder = self.p6_input_entry.getvalue() score_type = self.p6_scoretype_menu.getvalue() density_map = self.p6_map_entry.getvalue() density_map_threshold = self.p6_thresh_entry.getvalue() measure = self.p6_measuretype_menu.getvalue() threshold = self.p6_clusthresh_entry.getvalue() struct_nr = self.p6_numstruct_entry.getvalue() representation = self.p6_representation_menu.getvalue() output = self.p6_output_entry.getvalue() if self.oligos.get() == 1: oligomers = "oligo" else: oligomers = None if self.clustsort.get() == 1: sort_num = int(self.p6_clustsort_entry.getvalue()) else: sort_num = None start_clustering( infolder, score_type, density_map, density_map_threshold, measure, threshold, struct_nr, representation, output, oligomers, sort_num ) self.update_status("lime green", "Ready") tkMessageBox.showinfo( "Success", "Clustering results files can be found in " + output ) except Exception as e: tkMessageBox.showwarning("Error", e) self.update_status("lime green", "Ready")
def error_gui(message): """Simple tkinter gui for displaying errors """ tkMessageBox.showwarning('gozbruh Error:', message)
def load_GUI_resources(): "Load all extra modules and methods used by GUI" global askopenfilename, showinfo, showwarning, showerror, Tkinter from tkFileDialog import askopenfilename from tkMessageBox import showinfo,showwarning,showerror import Tkinter
def go_button_press(self): if self.root_element is None: tkMessageBox.showwarning("", "No experimental design specified.") else: RunnerSavePrompt(self) RunnerWindow(self)
def edit_button_press(self): if self.treeview.focus() == "": tkMessageBox.showwarning(None, "No element selected.") else: EditDialog(self, self, self.get_focused_element())
def menu_save(self): if len(self.cfg_file_name.get()) == 0: self.menu_saveas() elif self.root_element is None: tkMessageBox.showwarning(None, "Cannot save empty configuration.") else: try: with open(self.cfg_file_name.get(), "w") as handle: write_json(self.root_element.serialize(), handle) except IOError: tkMessageBox.showerror(None, "Failed to save config file.") else: tkMessageBox.showinfo(None, "Save successful:\n{}".format(self.cfg_file_name.get()))
def menu_saveas(self): if self.root_element is None: tkMessageBox.showwarning(None, "Cannot save empty configuration.") else: fname = tkFileDialog.asksaveasfilename() if len(fname) > 0: # file was selected try: with open(fname, "w") as handle: write_json(self.root_element.serialize(), handle) except IOError: tkMessageBox.showerror(None, "Failed to save config file.") else: self.cfg_file_name.set(fname) tkMessageBox.showinfo(None, "Save successful:\n{}".format(self.cfg_file_name.get()))
def validate(self): """ Validates the input. Returns ``True`` unless the field is blank and *optional* is ``False``. """ if not self.enabled: return True elif not self.optional and len(self.value.get()) == 0: tkMessageBox.showwarning("", "{} not specified.".format(self.text)) return False else: return True
def validate(self): if not self.enabled: return True elif len(self.value.get()) == 0: if not self.optional: tkMessageBox.showwarning("", "{} not specified.".format(self.text)) return False else: return True else: if os.path.exists(self.value.get()): if self.extensions is not None: if any(self.value.get().lower().endswith(x) for x in self.extensions): return True else: tkMessageBox.showwarning("", "Invalid file extension " "for {}.".format(self.text)) return False else: # no extension restriction return True else: tkMessageBox.showwarning("", "{} file does not exist." "".format(self.text)) return False
def validate(self): """ Returns ``True`` if the value entered validates; else ``False``. If *self.optional* is ``True``, the field can be empty. Checks the *self.minvalue* that was passed on creation. """ if not self.enabled: return True else: try: intvalue = int(self.value.get()) except ValueError: if len(self.value.get()) == 0: if not self.optional: tkMessageBox.showwarning("", "{} not specified." "".format(self.text)) return False else: return True else: tkMessageBox.showwarning("", "{} is not an integer." "".format(self.text)) return False else: if intvalue < self.minvalue: tkMessageBox.showwarning("", "{} lower than minimum value " "({}).".format(self.text, self.minvalue)) return False else: return True
def checkClearToRun(self): # sane = checkSubdirectorySanity(self.cwd, self.beta_folder) # if not sane: # tkMessageBox.showwarning( "Beta Folder", "Beta folder cannot be current directory, or ancestor.") # return False # clear, message, clean_up_beta, clean_up_results = self.checkGenerated() # if not clear: # answer = tkMessageBox.askokcancel(TS("Warning!"), message, icon=tkMessageBox.ERROR) # if answer: # self.cleanUpGenerated(clean_up_beta, clean_up_results) # else: # return False return True
def connectToServer(self): """Connect to the Server. Start a new RTSP/TCP session.""" self.rtspSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: self.rtspSocket.connect((self.serverAddr, self.serverPort)) except: tkMessageBox.showwarning('Connection Failed', 'Connection to \'%s\' failed.' %self.serverAddr)