How to make buttons like in example using python-telegram-bot? - python-telegram-bot

Nice telegrm bot's menu
I'm found an interesting menu on Telegram's #ShopBot
So right how i want to make menu for my bot, just like this one.
Where coud i find code examples or tutrorals how to make checkbox-like buttons like in this menu using python-telegram-bot framework ?

Try it:
#bot.message_handler(commands=['menu'])
def menu(m):
cid = m.chat.id
menuKeyboard = types.InlineKeyboardMarkup()
menuKeyboard.add(types.InlineKeyboardButton('Button1', callback_data='button1'),
types.InlineKeyboardButton('Button2', callback_data='button2'))
bot.send_message(cid, "Menu", reply_markup=menuKeyboard)

Related

RN Web, href in TouchableOpacity: onPress >navigation, onRight click > context menu with possibility to open link

I have a site with TouchableOpacity that uses react-navigation to navigate to another screen. Is it possible in some way to add href to this button so I could open the another screen in new tab using context menu "Open link in new tab"?
I know there is possibility to add accessibilityRole='link' href={''} to a component but what about a whole button of view.
This is according to: https://github.com/necolas/react-native-web/issues/162
Using Text component it is possible by:
<Text
accessibilityRole='link'
href={defineRightClick()}
target='_blank'
onPress={(e) => {
e.preventDefault();
navigateFunction();
}}>
Click to navigate, right click to open in new tab
</Text>
Ask if more information is needed for this question and I will edit it.
Every help is appreciated as I have tried to find solution but have not come across or found a way to handle this case.
Found an answer!
Even thought it is not documented in here: https://necolas.github.io/react-native-web/docs/accessibility/#accessibility-patterns
and using href in TouchableOpacity will show ts error No overload matches this call., it is possible to add to a TouchableOpacity props
accessibilityRole='link'
href={'desired link'}
target='_blank'
Then using e.preventDefault() in onPress event of TouchableOpacity will prevent link opening and do other things assigned to the function. At the same time the link is possible to be opened with right click > context menu > "Open link in new tab"
I will post this as answer so if anyone else comes across this they might find the solution

How to have only one tab open in wxribbon bar in wxpython?

I am building a GUI and I am using wxribbon for wxpython. I want to have only one tab(ribbon page) in when user starts my app, from where user can dynamically add more pages or can add panels and buttons to a page. I am able to achieve all the dynamic parts of ribbon. The only problem I have is that I am unable to start with only one ribbon page. When I define only one page, I don't see the ribbon bar(tab bar), what I see is only the page. Now, when I define two page in the beginning, then I see the bar. Can someone tell me what I code have to change in wxribbon so that I am able to have a tab bar visible with only one page in it. Any help would be great. Thanks!. The sample code I am using to add a page is as follows :
import wxRibbon as RB
self._ribbon = RB.RibbonBar(self, id = wx.ID_ANY)
page_1 = RB.RibbonPage(self._ribbon, WORKPIECE, "Workpiece", Bitmap("eye.xpm"))
page_2 = RB.RibbonPage(self._ribbon, wx.ID_ANY, "New Tab", Bitmap("empty.xpm"))
You need the flag RIBBON_BAR_ALWAYS_SHOW_TABS
try this:
self._ribbon = RB.RibbonBar(self, wx.ID_ANY, agwStyle = RB.RIBBON_BAR_DEFAULT_STYLE | RB.RIBBON_BAR_ALWAYS_SHOW_TABS)

How go from one UI to another UI on Image button click event in juce introjucer?

can you please tell me How go from one UI to another UI on Image button click event in juce introjucer?
Basically you have to:
1.- Parent component must inherit from ButtonListener, and you must implement the buttonclicked method
void WindowComponent::buttonClicked (Button* activeButton)
{
if (activeButton == &someButton)
{
gotoOtherPage();
}
}
2.- Your "UIs" i must suppose are components, if so just do something like:
component.setVisible(false),
otherComponent.setVisible(true),
Or perhaps stash them in a TabbedComponent, hide the tabs or overlap some buttons and then just do:
tabbedComponent.setCurrentTabIndex(someIndex);
That should get you going, in case you need help to draw a button just do something like:
addAndMakeVisible (&someButton);
someButton.setBounds(...);
someButton.addListener(this);
Check out the doxygen docs, they are quite helpful.

Google Apps Script listbox to dropdown box

I'm building a UI in Google Sites using Apps Script and I am able to create a listbox. According to the documentation if you change the setVisibleItemCount to 1 it will become a dropdown box.
I have tried both 1 and 0.
Neither seems to make it a drop-down box. Using Firefox 13.0.1 to view. Have also tried Safari.
Anyone had any luck with this?
Code looks like this:
var vPanel = container.createVerticalPanel();
//List box
var lb = container.createListBox(true).setId('listbox').setName('listbox');
// add items to ListBox
for(var i=0;i<LIST_OF_PROJECTS.length;i++){
lb.addItem(LIST_OF_PROJECTS[i]);
}
vPanel.add(lb);
lb.setVisibleItemCount(1); //supposed to make it a drop-down but doesn't
lb.setSelectedIndex(0);
This is all inside a Google Site and the page that is being displayed is a Apps Script Page. Perhaps you are NOT using Google Sites? Above code gives me a single line but no drop down arrow.
Could you post your relevant code please ?, It's working for me on firefox (slightly differently), chrome & safari. (see screen cap when I click the selector, SetVisibleItemCount is 1)
thx
EDIT : One important point : to get the list acting as a dropdown list you have to choose 'disable multiple selection', in other words : createListBox(false) or no parameter... but not 'true' as it is in your code !! (now we know why it doesn't work in your case ;-)
With this parameter set to false , it works as expected in standalone webapp, embedded on site and linked to spreadsheet without any difference.
Don't call:
setVisibleItemCount
at all.

How Do You Change the Title of a Page in wx.aui.AuiNotebook?

So I'm working on a text editor to better learn wxPython (and to make a text editor that I really like :P). I have been having trouble finding much info on the wx.aui.AuiNotebook class. One thing I would like to know is how to interact with its pages. For example, I would really like to know how to change the title of a page (so that I can update the page title when a user saves or to mark it when there is unsaved changes). Any assistance on this matter would be most appreciated!
The method is called SetPageText, so you would do something like:
current_page = notebook.GetCurrentPage()
current_page_index = notebook.GetPageIndex(current_page)
current_label = notebook.GetPageText(current_page_index)
if not current_label.endswith(' (*)':
notebook.SetPageText(current_page_index, current_label + ' (*)')
Apparently, in wxPython version 2.8 does not include wx.aui.AuiNotebook.GetCurrentPage(). What I apparently didn't realize is that a "page" in the wx.aui.AuiNotebook is equivalent to the panel that is being added to it. Thus the following code will work,
self.panelBox = []
newPanel = wx.Panel(self, wx.ID_ANY)
#YADA YADA STUFF!
self.nb.AddPage(newPanel, "Untitled Document "+str(self.untitledDocCount))
currPageIndex = self.nb.GetPageIndex(newPanel)
currLabel = self.nb.GetPageText(currPageIndex)
if not currLabel.endswith(' (*)'):
self.nb.SetPageText(currPageIndex, currLabel+' (*)')
self.panelBox.append(newPanel)
It's up to the programmer to ensure that the pages (panels) are accessible. I do this by storing the panel references in a "panel box" and then switching between them accordingly in conditions such as a "change tab" event. I don't know if this is the best way to do this, but it appears to work so far.

Resources