本文整理汇总了Python中javax.swing.JOptionPane类的典型用法代码示例。如果您正苦于以下问题:Python JOptionPane类的具体用法?Python JOptionPane怎么用?Python JOptionPane使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JOptionPane类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
def update(self,button=None): #human triggered
print 'current1', self.current_player
if(button!=None):
#human
cell = str(button.row) + str(button.col)
if cell in self.empty_cells and self.current_player.level=='human':
self.current_player.turn(button)
self.update_state()
if (self.state == 'next'):
self.switch_turn()
print 'current2', self.current_player
if self.current_player.level != 'human':
#ai!
print "before ai's turn", self.current_player, self.board, self.empty_cells
self.current_player.turn()
self.update_state()
if (self.state == 'next'):
self.switch_turn()
print "after ai's turn", self.current_player, self.board, self.empty_cells
print 'update', self.state, self.turn
if self.state == 'over':
JOptionPane.showMessageDialog(self.ui.panel,
"Game Over! Player: " + self.current_player.name + " Wins!!",
"Winner", JOptionPane.INFORMATION_MESSAGE)
elif self.state == 'draw':
JOptionPane.showMessageDialog(self.ui.panel,
"Its a draw!",
"Draw", JOptionPane.INFORMATION_MESSAGE)
示例2: vulnNameChanged
def vulnNameChanged(self):
if os.path.exists(self.getCurrentVulnPath()) and self.vulnName.getText() != "":
self.addButton.setText("Update")
elif self.addButton.getText() != "Add":
options = ["Create a new vulnerability", "Change current vulnerability name"]
n = JOptionPane.showOptionDialog(None,
"Would you like to?",
"Vulnerability Name",
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE,
None,
options,
options[0]);
if n == 0:
self.clearVulnerabilityTab(False)
self.addButton.setText("Add")
else:
newName = JOptionPane.showInputDialog(
None,
"Enter new name:",
"Vulnerability Name",
JOptionPane.PLAIN_MESSAGE,
None,
None,
self.vulnName.getText())
row = self.logTable.getSelectedRow()
old = self.logTable.getValueAt(row,1)
self.changeVulnName(newName,old)
示例3: actionPerformed
def actionPerformed(self, event):
content, message, info, parameter = self.tab._current
try:
body = content[info.getBodyOffset():].tostring()
if parameter is not None:
param = self.tab.helpers.getRequestParameter(
content, parameter.getName())
if param is not None:
rules = self.tab.extender.table.getParameterRules().get(parameter.getName(), {})
body = param.getValue().encode('utf-8')
for rule in rules.get('before', []):
body = rule(body)
message = parse_message(self.descriptor, body)
self.tab.editor.setText(str(message))
self.tab.editor.setEditable(True)
self.tab._current = (content, message, info, parameter)
except Exception as error:
title = "Error parsing message as %s!" % (self.descriptor.name, )
JOptionPane.showMessageDialog(self.tab.getUiComponent(),
error.message, title, JOptionPane.ERROR_MESSAGE)
return
示例4: promptInfoPane
def promptInfoPane(self, text):
'''
1. Show popup with given information text
'''
JOptionPane.showMessageDialog( \
self.view.getContentPane(), text, "Information", \
JOptionPane.INFORMATION_MESSAGE)
示例5: on_falsePositiveBtn_clicked
def on_falsePositiveBtn_clicked(self, event):
"""Tell the tool server that selected error is a false positive
"""
check = self.selectedError.check
tool = check.tool
if tool.falseFeedbackMode == "url":
#the tool supports automatic reporting
if self.properties.getProperty("false_positive_warning.%s" % tool.name) == "on":
messageArguments = array([tool.title], String)
formatter = MessageFormat("")
formatter.applyPattern(self.strings.getString("false_positive_confirmation"))
msg = formatter.format(messageArguments)
options = [self.strings.getString("yes_do_not_ask_the_next_time"),
self.strings.getString("Yes"),
self.strings.getString("No")]
answer = JOptionPane.showOptionDialog(Main.parent,
msg,
self.strings.getString("flagging_a_false_positive"),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE,
None,
options,
options[2])
if answer == 0:
#don't ask again
self.properties.setProperty("false_positive_warning.%s" % tool.name,
"off")
self.save_config(self)
elif answer == 2:
#don't flag as false positive
return
tool.sayFalseBug(self.selectedError, check)
elif tool.falseFeedbackMode == "msg":
#the tool supports manual reporting of false positives
if self.properties.getProperty("false_positive_warning.%s" % tool.name) == "on":
messageArguments = array([tool.title], String)
formatter = MessageFormat("")
formatter.applyPattern(self.strings.getString("manual_false_positive_confirmation"))
msg = formatter.format(messageArguments)
options = [self.strings.getString("yes_do_not_ask_the_next_time"),
self.strings.getString("Yes"),
self.strings.getString("No")]
answer = JOptionPane.showOptionDialog(Main.parent,
msg,
self.strings.getString("flagging_a_false_positive"),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE,
None,
options,
options[2])
errorInfo = [tool.title,
check.name,
self.selectedError.errorId,
self.selectedError.osmId]
self.falsePositiveDlg.tableModel.addRow(errorInfo)
else:
#the tool does not support feedback
return
self.editDone()
示例6: on_downloadBoundariesBtn_clicked
def on_downloadBoundariesBtn_clicked(self, e):
"""Download puter ways of administrative boundaries from
Overpass API
"""
adminLevel = self.adminLevelTagTextField.getText()
name = self.nameTagTextField.getText()
optional = self.optionalTagTextField.getText()
if (adminLevel, name, optional) == ("", "", ""):
JOptionPane.showMessageDialog(self,
self.app.strings.getString("enter_a_tag_msg"),
self.app.strings.getString("Warning"),
JOptionPane.WARNING_MESSAGE)
return
optTag = ""
if optional.find("=") != -1:
if len(optional.split("=")) == 2:
key, value = optional.split("=")
optTag = '["%s"="%s"]' % (URLEncoder.encode(key, "UTF-8"),
URLEncoder.encode(value.replace(" ", "%20"), "UTF-8"))
self.create_new_zone_editing_layer()
overpassurl = 'http://127.0.0.1:8111/import?url='
overpassurl += 'http://overpass-api.de/api/interpreter?data='
overpassquery = 'relation["admin_level"="%s"]' % adminLevel
overpassquery += '["name"="%s"]' % URLEncoder.encode(name, "UTF-8")
overpassquery += '%s;(way(r:"outer");node(w););out meta;' % optTag
overpassurl += overpassquery.replace(" ", "%20")
print overpassurl
self.app.send_to_josm(overpassurl)
示例7: getFirstSymbol
def getFirstSymbol():
color_alpha_width = {}
activeLayers=getActiveLayers()
if (len(activeLayers)>0):
lyr=activeLayers[0]
if lyr.getClass().getCanonicalName() == "com.iver.cit.gvsig.fmap.layers.FLyrVect":
legend=lyr.getLegend()
print legend
if legend.getClassName() == 'com.iver.cit.gvsig.fmap.rendering.SingleSymbolLegend':
sym = legend.getDefaultSymbol()
color_alpha_width["color"] = sym.getColor()
color_alpha_width["alpha"] = sym.getAlpha()
if (sym.getClassName() == 'com.iver.cit.gvsig.fmap.core.symbols.SimpleLineSymbol'):
color_alpha_width["width"] = sym.getLineWidth()
elif legend.getClassName() == 'com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend':
sym = legend.getSymbol(0)
if (sym.getClassName() == 'com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol'):
color_alpha_width["color"] = sym.getOutline().getColor()
color_alpha_width["width"] = sym.getOutline().getLineWidth()
color_alpha_width["alpha"] = sym.getOutline().getAlpha()
else:
try:
color_alpha_width["color"] = sym.getOutline().getColor()
color_alpha_width["width"] = sym.getOutline().getLineWidth()
color_alpha_width["alpha"] = sym.getOutline().getAlpha()
except Exception, e:
JOptionPane.showMessageDialog(None, legend.getClassName() + " not yet implemented!",
"Border Symbology", JOptionPane.WARNING_MESSAGE)
close(e)
示例8: printDB
def printDB(self, e):
out = ""
for a in self._db.arrayOfUsers:
out += str(a._index)+" "+a._name+" : "+str(a._roles)+"\n"
for b in self._db.arrayOfMessages:
out += str(b._index)+" "+str(b._roles)+"\n"
JOptionPane.showMessageDialog(self._splitpane,out)
示例9: main
def main():
b=BuildingInBuilding()
if Main.main and Main.main.map:
mv= Main.main.map.mapView
print mv.editLayer
if mv.editLayer and mv.editLayer.data :
selectedNodes = mv.editLayer.data.getSelectedNodes()
selectedWays = mv.editLayer.data.getSelectedWays()
if not(selectedWays):
JOptionPane.showMessageDialog(Main.parent, "Please select a set of ways")
else:
print "going to output ways";
for way in selectedWays:
#is there a
housenumber=way.get('addr:housenumber')
street=way.get('addr:street')
if(housenumber):
b.visitw(way)
# print 'house box:', street, housenumber
for node in selectedNodes:
housenumber=node.get('addr:housenumber')
street=node.get('addr:street')
if(housenumber):
b.visitn(node)
l.showNode(node)
# print 'house box:', street, housenumber
b.endTest()
示例10: _validate_form
def _validate_form(self):
error_message = ''
try:
original_hash = hex_to_raw(self._textfields["original_hash"].getText())
except Exception:
error_message += "Original hash doesn't look right.\n"
try:
max_key_len = int(self._textfields["max_key_len"].getText())
except Exception:
error_message += "Max key length needs to be an integer.\n"
original_msg = self._textfields["original_msg"].getText().encode()
append_msg = self._textfields["append_msg"].getText().encode()
if not original_msg:
error_message += "Missing original message.\n"
if not append_msg:
error_message += "Missing message to append.\n"
if error_message:
JOptionPane.showMessageDialog(self._tab, error_message, "Form Validation Error", JOptionPane.WARNING_MESSAGE)
return False
return True
示例11: purge_old_birch
def purge_old_birch():
print_label("Purging old BIRCH")
os.chdir(ARGS.install_dir)
contents=os.listdir(os.getcwd())
if "install-birch" in contents:
for each in birch_files:
if (each!="local" and each.count("birch_backup")!=1 and os.path.lexists(ARGS.install_dir+"/"+each)):
print_console("Removing old BIRCH component: "+each)
filename=ARGS.install_dir+"/"+each
if (os.path.isdir(filename)):
try:
shutil.rmtree(filename)
if (os.path.isdir(filename)):
os.remove(filename)
except:
err=traceback.format_exc()
print_console(err)
JOptionPane.showMessageDialog(None, "An error occurred deleting file: "+filename)
else:
pass
示例12: actionPerformed
def actionPerformed(self, event):
if _num.getValue() > 8:
JOptionPane.showMessageDialog(None, "Max value reached. Resetting to zero.")
_num.setValue(0)
else:
_num.increment()
otText.setText(str(_num))
示例13: move_script_warning
def move_script_warning():
"""Warn the user to move qat_script directory into Scripting Plugin
directory
"""
scriptingPluginDir = PluginHandler.getPlugin("scripting").getPluginDir()
pane = JPanel(GridLayout(3, 1, 5, 5))
warningTitle = "Warning: qat_script directory not found"
pane.add(JLabel("Please, move qat_script directory to the following location and start the script again:\n"))
defaultPathTextField = JTextField(scriptingPluginDir,
editable=0,
border=None,
background=None)
pane.add(defaultPathTextField)
if not Desktop.isDesktopSupported():
JOptionPane.showMessageDialog(
Main.parent,
pane,
warningTitle,
JOptionPane.WARNING_MESSAGE)
else:
#add a button to open default path with the files manager
pane.add(JLabel("Do you want to open this folder?"))
options = ["No", "Yes"]
answer = JOptionPane.showOptionDialog(
Main.parent,
pane,
warningTitle,
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
None,
options,
options[1])
if answer == 1:
Desktop.getDesktop().open(File(scriptingPluginDir))
示例14: play_event
def play_event(self, x1, y1, x2, y2):
status = self.puzzle.play(x1, y1, x2, y2)
self.draw_board()
if status == SimplePyzzle.END_GAME:
JOptionPane.showMessageDialog (None, \
"Grats! You solved the puzzle", \
"Puzzle solved!", \
JOptionPane.INFORMATION_MESSAGE);
示例15: aboutAction
def aboutAction(self, e):
aboutText = """Induction Applet v. 0.1
(c) 2007 University of Düsseldorf
Authors: Gerhard Schurz, Eckhart Arnold
"""
aboutText = re_sub(" +", " ", aboutText)
JOptionPane.showMessageDialog(self.getContentPane(), aboutText)