I have a report where, once the user clicks a SAVE button it fires a script. Can I do a dialog box where once the user clicks SAVE, A dialog with "Confirm save ... Yes? No? " pops up and when the user clicks Yes it fires the script? I would like this to work on both the web player and desktop
You can use the following iron python script for solving this:
import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import MessageBox, MessageBoxButtons
from System.Windows.Forms import DialogResult
dialogResult = MessageBox.Show("Some question", "Some Title", MessageBoxButtons.YesNo)
if(dialogResult == DialogResult.Yes):
MessageBox.Show("The answer is YES")
else:
MessageBox.Show("The answer is NO")
Related
I have a problem.
I created a telegram bot under python3 with telepot and I use a custom keyboard.
the problem is that when i press a button, the custom keyboard is hidden by the phone keypad.
is it possible to temporarily lock the custom keyboard open or block the phone keyboard?
I already tested one_time_keyboard and it didn't work.
markupmainmenuadmin = ReplyKeyboardMarkup(keyboard=[["menu 1"],["info 1"],["info 2"],["info 3"],["Admin"]],resize_keyboard = True,one_time_keyboard = True)
[...]
bot.sendMessage(chat_id,str(textdb.get(query.nom == 'MainMenu2').get("text")),disable_web_page_preview=True, reply_markup=markupmainmenuadmin, parse_mode= 'Markdown')
it only happens when you stay on the same keyboard.
markupmainmenuadmin =InlineKeyboardMarkup(inline_keyboard=[[InlineKeyboardButton(text="menu 1", callback_data='0')],[InlineKeyboardButton(text="info 1", callback_data='1')],[InlineKeyboardButton(text="info 2", callback_data='2')],[InlineKeyboardButton(text="info 3", callback_data='3')],[InlineKeyboardButton(text="Admin", callback_data='4')]])
I'm automation a notepad GUI developed in PYQT5 using PYtestqt. when I try to click the menu bar or toolbar options using qtbot it is not simulating the click
def test_quit(qtbot):
window = MainWindow()
qtbot.add_widget(window)
window.show()
qtbot.wait_for_window_shown(window)
qtbot.mouseClick(window.file_menu, QtCore.Qt.LeftButton)
I was trying to find a way to trigger an action under a menu. Since you most likely want to trigger an action (item under the menu), this may help you as well. Instead of using qtbot, use the window directly and call trigger. So something like this:
def test_quit(qtbot):
window = MainWindow()
qtbot.add_widget(window)
window.show()
qtbot.wait_for_window_shown(window)
window.file_quit_action.trigger()
if you wanna just trigger the click event connected action, you can try this.
In MainWindow class:
# binding action and function
action_open = QAction("Open", self)
action_open.setCheckable(False)
action_open.setObjectName("action_open") # Notice set a object name
action_open.triggered.connect(self.file_open)
In test scripts:
def test_file_open_action(qtbot):
window = MainWindow()
qtbot.add_widget(window)
window.show()
win.findChild(QAction, 'action_open').trigger() # call the method
So you can get the same result after simulate click memubar widget.
I want to show the text from the 'Yes' and the 'No' button in the informative text of a QMessageBox, but I don't see how I can get these labels from the buttons.
from PyQt5.QtWidgets import *
import sys
app = QApplication(sys.argv)
msgbox = QMessageBox()
msgbox.setStandardButtons(msgbox.Yes | msgbox.No)
info_text = "Click '{yes}' to confirm. Click '{no}' to abort."
msgbox.setInformativeText(info_text)
if msgbox.exec_() == msgbox.Yes:
print("Confirmed")
else:
print("Aborted")
By calling setStandardButtons, the button order and the button labels will be set to the default for the current operating system and the current language setting. How can I obtain these defaults so that I can use them for the slots in the string info_text?
I thought about using the buttons attribute from the QMessageBox object, which is a list of QPushButton objects. I can read the labels from there, but I don't see how I could determine whether the first element in the list is the Yes or the No button.
Okay, I was being stupid: along side the buttons attribute, there is also the button() method, which takes as its argument the button type that I want to retrieve. I can then use text() to get the label. Finally, the hotkey marker & has to be stripped from the label:
info_text = "Click '{yes}' to confirm. Click '{no}' to abort.".format(
yes=msgbox.button(msgbox.Yes).text().replace("&", ""),
no=msgbox.button(msgbox.No).text().replace("&", ""))
msgbox.setInformativeText(info_text)
I have a script that enables a Power supply after the user click "ONLY ONE TIME" the "START TEST" button, right after, I disable the button to avoid the "double click, however, I have noticed that "some how" if user perform a "double click" my application launch a second operation.
def starttest():
Button(main, text="START TEST", font=("Tahoma", 21), height=1, width=24,
command=starttest, state=DISABLED).place(x=55,y=40)
PS = serial.Serial('COM1', 9600, timeout=.1)
##my code here ...
Does anyone have an idea what should I do to prevent this happen?
Each time you call starttest() function by pressing the inherent button, a new button widget is created: that is why it looks like you are able to click indefinitely on the falsely "same" button.
You should create that button somewhere else in your program:
...
power_supply_btn = Button(... text="START TEST", command=starttest ...)
power_supply_btn.place(x=55,y=40)
...
Then configure the state of that button in your starttest() callback using the configure() function:
def starttest():
global power_supply_btn
power_supply_btn.configure(state=DISABLED)
How can I fetch the selection of a pop-up menu after the user has selected "his" item and then pressed "Done"?
The selected can be displayed with:
var clicked = document.getElementById("popup").value;
alert(clicked);
And, how can I zoom out, after this item has been selected?
I have put a "ChangeHandler" on the pop-up men
function myChangeHandler(event) {
var clicked = document.getElementById("popup").value;
alert(clicked);
}
BR,
Stefan