I'm creating a wrapper for /commands in python
I created an InlineKeyboardButton with a URL to chat the bot in private. I want the button to remove or disappear, just not show after the user clicks the url button.
I have used the generic wrapper from the telegram tutorials.
However, I am a "newb" :) Always trying to learn something new I can share.
In this case, I've become stuck.
Unlike callback_data where data can be sent to another button to edit the message. The URL doesn't send anything. I just want the button to vanish or the best alternative hide or something.
Any Ideas??
what direction to move in :)
I have looked into ReplyKeyboardRemove and OneTimeKeyboard but either my syntax is off or It isn't possible with a URL button
def myrestricted(func):
#wraps(func)
def wrapped(bot, update):
user = update.message.from_user.username
if update.message.chat.type != "private" :
group = update.message.chat.id
if user not in ADMIN_ONLY:
button = [InlineKeyboardButton("7heUnknown_Bot", url='t.me/7heUnknown_Bot',],
bot.send_message(chat_id=update.message.chat_id, text="Please click the button below to talk with me privately")
return
return func(bot, update)
return wrapped```
When the user clicks on the URL button I want the button to disappear.
Unfortunately, you can't.
InlineKeyboardButton with a URL only displays the button for users to open a link. As far as I know, there's no event in Telegram's API that can be fired when the user actually opens the link (or even clicks on the button!)
Related
In a window class I have this button...
encrypt_button = QPushButton("Generate")
encrypt_button.setProperty('class', 'warning')
encrypt_button.clicked.connect(
lambda: encrypt_message(encrypt_message_box.toPlainText(), encrypt_public_key_box.toPlainText(),
encrypt_output_box))
encrypt_button.setObjectName("encrypt_button")
The encrypt_message function opens a error QMessageBox if there are values missing...and all works fine.
But I've come to write a unittest and I cannot seem to test for it opening...when I simulate the button click the window actually opens and will not continue until I click OK
def test_copy(self):
""" checks to make sure the button doesn't copy when its blank """
for button in self.window.copy_buttons:
button.click()
##some test here
I've enlisted the help of our friendly AI helper, who keeps telling me to use QSignalSpy or qWaitForWindowExposed, but everything I try just results in the same thing. The QMessageBox opens and I'm stuck waiting for user input.
Any suggestions?
I have a select menu with a submit button. When submit is clicked I want to close the current message, submit the data and then open a new select menu but I am having trouble figuring out how to have the message close.
How can I have the current menu and button close when the submit button is clicked?
Thanks in advance for your help.
To turn my comment into an answer; you can just delete the message on button press. For example, my Cancel buttons look a little like this:
#discord.ui.button(label="Cancel", style=discord.ButtonStyle.red, row=3, disabled=False, emoji="✖️")
async def cancel_callback(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.message.delete()
This is within a custom View class so might have to be adapted for your needs - but using the interaction.message attribute to delete the message is the way to go.
I'm new in Tkinter and I'm currently trying to create a small game. When something happens in the game I want to create a pop-up window which will inform the user about any changes. This is the code that I have written for it.
def message(self, text):
top = tkinter.Toplevel(width=50, height=25)
top.title("Message")
msg = tkinter.Message(top, text=text)
msg.pack()
ok = tkinter.Button(top, text="OK", command=top.destroy)
ok.pack()
My two questions are:
Can I replace this by an exception that will create an "Error Message" window? If it isn't necessary then can I use it to be raised by the exception?
I want the user to be forced to see and read the message, so how can I freeze the main window(the user can't click on anything else) until he presses the OK button on the pop-up window?
Use:
top.grab_set()
To show Error Message you can use tkmessagebox.showerror().
I'm using EPD traits for a basic GUI interface. I'm able to pop up a settings window using code like this:
settings_w.configure_traits(kind="livemodal")
The window has 'OK' and 'Cancel' buttons and I want to do something different depending on which button was pressed to exit the window. Seems like it should be simple but I can't figure out how to set this up.
Theoretically I'd like to do something like this:
# Display the settings widget
settings_w.configure_traits(kind="livemodal")
if settings_w.CancelButtonPressed:
pass
else:
print "I got the input"
But let me know if there's a better or more correct way to do this.
Also FWIW: here's the view properties of my settings window with standard OK and Cancel buttons:
view = View(
settings_group,
title = 'Settings Editor',
width = 500,
buttons = [OKButton, CancelButton, 'Help' ],
kind = 'modal',
handler = SaveRestore_Handler()
)
If I understand the question, checking the output of configure_traits should do what you want:
result = settings_w.configure_traits(kind="livemodal")
if result:
print "The user pressed OK."
else:
print "The user pressed Cancel or closed the window."
On the webpage, when I create a new user, alert message displayed that 'New user was created'. And in order to continue, I have to click button 'ok'. So the thing is I don't really know how to click it.
when I need to click a regular button I do something like this:
doc = self.page().currentFrame().documentElement()
submit_button = doc.findFirst('input[id=my-submit-button]')
submit_button.evaluateJavaScript('this.click()')
But how to click button in alert message?
You are looking for the QWebPage::javaScriptAlert ( QWebFrame * frame, const QString & msg ) function:
This function is called whenever a JavaScript program running inside
frame calls the alert() function with the message msg.
The default implementation shows the message, msg, with
QMessageBox::information.