Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello โ I'm @olemoritz on Twitter.
Keyboard ui button.
-
I've made a keyboard application. I want to make a list of Emoji by its development.
Can I use the ui button to create a different window?
-
@shinya.ta I want to help you but I don't understand your request.
-
It is a window that replaces the task bar.
If you register a lot of Emoji on the task bar, the text field is filled and it becomes difficult to check the sentence.
In the Emoji list of emoji on the iPhone, there are too many emoji to use, so I want to open the window that I can go on a screen with a button.
-
@shinya.ta Sorry, I still don't understand. You speak about a keyboard application, what is the textfield? How is it filled?
-
@shinya.ta Do you want to say, in my little script using setInputAccessoryView, you want to display emojis not all in one shot but in several parts with a button to get the next set?
-
@shinya.ta If I correctly understood, try this at the end of your script (if based on mine)
def nextSet(sender): i_set = sender.i_set + 1 if i_set == sender.n_sets: i_set = 0 #attach our accessory to the textfield, and textview ww = vv_array[i_set] tvo = tv.objc_instance #print(dir(tvo)) tvo.setInputAccessoryView_(ObjCInstance(ww)) tvo.reloadInputViews() #create normal keys d = 32 dd = 4 emojis = '๐๐๐ฑ๐ฆโ๏ธ๐๐๐๐๐๐ ๐๐คฃโบ๏ธ๐๐๐๐๐๐๐๐ฅฐ๐๐๐๐๐๐๐๐๐คช๐คจ๐ง๐ค๐๐คฉ๐ฅณ๐๐๐๐๐๐๐โน๏ธ๐ฃ๐๐ซ๐ฉ๐ฅบ๐ข๐ญ๐ค๐ ๐ก๐คฌ๐คฏ๐ณ๐ฅต๐ฅถ๐ฑ๐จ๐ฐ๐ฅ๐๐ค๐ค๐คญ๐คซ๐คฅ๐ถ๐๐๐ฌ๐ฆ๐ง๐ฎ๐ฒ๐ด๐คค๐ช๐ต๐ค๐ฅด๐คข๐คฎ๐คง๐ท๐ค๐ค๐ค๐ค ๐' n_sets = 4 vv_array = [] for i_set in range(0,n_sets): l = int(len(emojis)/n_sets) i = i_set * l set_emojis = emojis[i:i+l] + 'โฉ' w, h = ui.get_screen_size() vv = ui.View(name='set'+str(i_set)) vv.background_color = 'lightgray' h = 0 x = dd y = dd for button_title in set_emojis: b = ui.Button(title=button_title) if button_title == 'โฉ': b_action = nextSet b.i_set = i_set b.n_sets = n_sets b.name = 'nextSet' else: b_action = typeChar b.action=b_action b.frame = (x,y,d,d) b.font = ('.SFUIText', d) if (y+d+dd) > h: h = y + d + dd vv.add_subview(b) x = x + d + dd if (x+d+dd) > w: x = dd y = y + d + dd vv.frame = (0,0,w,h) vv_array.append(vv) i_set = 0 nextSet(vv_array[n_sets-1]['nextSet']) # display 1st set v.present('sheet') tv.selected_range = (0,0) tv.begin_editing()
-
It's a little different from what I was thinking, but that's a good idea.
b_action = typeChar
Here is a name error.
Why? -
@shinya.ta It was the action of my old script
def typeChar(sender): '''finds active textinput, and types the button's title''' tf=sender.objc_instance.firstResponder() tf.insertText_(sender.title)
But I don't know what your script became....
-
@shinya.ta And it is only an example of what you could do. You could have any button with the title or image you want to display next set of emojis.
-
-
It was successful.
I want to use this application vertically, so I hope the display of emoji is less.
How can I adjust the number of emoji?
-
@shinya.ta Hello
The n_sets sets the number of sets
You could set the number of emojis you want per set and then compute the number of setsn_emojis_in_set = 20 n_sets = 1 + int((len(emojis)-1)/n_emojis_in_set)
-
@shinya.ta please let me know if it is ok and if you want to put the "next set" button at another place
-
Dear.cvp
n_emojis_in_set = 20 n_sets = 1 + int((len(emojis)-1)/n_emojis_in_set)
Where should I put this code in?
I tried to put it in the last line, but there was no change. -
It is the best if I can set this emoji to the task bar only by the operation of my wife who is visually impaired.
Is Pythonisa possible to set up a button only with buttons, not in the operation of the program?
-
@shinya.ta instead of
emojis = '๐๐๐ฑ๐ฆโ๏ธ๐๐๐๐๐๐ ๐๐คฃโบ๏ธ๐๐๐๐๐๐๐๐ฅฐ๐๐๐๐๐๐๐๐๐คช๐คจ๐ง๐ค๐๐คฉ๐ฅณ๐๐๐๐๐๐๐โน๏ธ๐ฃ๐๐ซ๐ฉ๐ฅบ๐ข๐ญ๐ค๐ ๐ก๐คฌ๐คฏ๐ณ๐ฅต๐ฅถ๐ฑ๐จ๐ฐ๐ฅ๐๐ค๐ค๐คญ๐คซ๐คฅ๐ถ๐๐๐ฌ๐ฆ๐ง๐ฎ๐ฒ๐ด๐คค๐ช๐ต๐ค๐ฅด๐คข๐คฎ๐คง๐ท๐ค๐ค๐ค๐ค ๐' n_sets = 4 vv_array = []
Do
emojis = '๐๐๐ฑ๐ฆโ๏ธ๐๐๐๐๐๐ ๐๐คฃโบ๏ธ๐๐๐๐๐๐๐๐ฅฐ๐๐๐๐๐๐๐๐๐คช๐คจ๐ง๐ค๐๐คฉ๐ฅณ๐๐๐๐๐๐๐โน๏ธ๐ฃ๐๐ซ๐ฉ๐ฅบ๐ข๐ญ๐ค๐ ๐ก๐คฌ๐คฏ๐ณ๐ฅต๐ฅถ๐ฑ๐จ๐ฐ๐ฅ๐๐ค๐ค๐คญ๐คซ๐คฅ๐ถ๐๐๐ฌ๐ฆ๐ง๐ฎ๐ฒ๐ด๐คค๐ช๐ต๐ค๐ฅด๐คข๐คฎ๐คง๐ท๐ค๐ค๐ค๐ค ๐' n_emojis_in_set = 20 n_sets = 1 + int((len(emojis)-1)/n_emojis_in_set) vv_array = []
-
@shinya.ta Sorry, I don't understand this
It is the best if I can set this emoji to the task bar only by the operation of my wife who is visually impaired. Is Pythonisa possible to set up a button only with buttons, not in the operation of the program?
If I correctly understand, you want to ask this "next set of emojis" by a normal button.
But where do you want this button? -
Sorry for the poor English.
It is a button that my wife can set emoji by herself.
The location of the button is okay anywhere.
-
@shinya.ta Try
#create normal keys d = 32 dd = 4 emojis = '๐๐๐ฑ๐ฆโ๏ธ๐๐๐๐๐๐ ๐๐คฃโบ๏ธ๐๐๐๐๐๐๐๐ฅฐ๐๐๐๐๐๐๐๐๐คช๐คจ๐ง๐ค๐๐คฉ๐ฅณ๐๐๐๐๐๐๐โน๏ธ๐ฃ๐๐ซ๐ฉ๐ฅบ๐ข๐ญ๐ค๐ ๐ก๐คฌ๐คฏ๐ณ๐ฅต๐ฅถ๐ฑ๐จ๐ฐ๐ฅ๐๐ค๐ค๐คญ๐คซ๐คฅ๐ถ๐๐๐ฌ๐ฆ๐ง๐ฎ๐ฒ๐ด๐คค๐ช๐ต๐ค๐ฅด๐คข๐คฎ๐คง๐ท๐ค๐ค๐ค๐ค ๐' n_emojis_in_set = 20 n_sets = 1 + int((len(emojis)-1)/n_emojis_in_set) vv_array = [] for i_set in range(0,n_sets): l = int(len(emojis)/n_sets) i = i_set * l set_emojis = emojis[i:i+l] w, h = ui.get_screen_size() vv = ui.View(name='set'+str(i_set)) vv.background_color = 'lightgray' h = 0 x = dd y = dd for button_title in set_emojis: b = ui.Button(title=button_title) b_action = typeChar b.action=b_action b.frame = (x,y,d,d) b.font = ('.SFUIText', d) if (y+d+dd) > h: h = y + d + dd vv.add_subview(b) x = x + d + dd if (x+d+dd) > w: x = dd y = y + d + dd vv.frame = (0,0,w,h) vv_array.append(vv) tv.i_set = 0 tv.n_sets = n_sets def nextSet(sender): tv.i_set = tv.i_set + 1 if tv.i_set == tv.n_sets: tv.i_set = 0 #attach our accessory to the textfield, and textview ww = vv_array[tv.i_set] tvo = tv.objc_instance #print(dir(tvo)) tvo.setInputAccessoryView_(ObjCInstance(ww)) tvo.reloadInputViews() nextSet(vv_array[n_sets-1]['nextSet']) # display 1st set # add a button at right of "typing suggestions", just above the keyboard bb_target = ui.Button() bb_target.action = nextSet UIBarButtonItem = ObjCClass('UIBarButtonItem').alloc().initWithTitle_style_target_action_('Next Emojis',0,bb_target,sel('invokeAction:')).autorelease() #UIBarButtonItem = ObjCClass('UIBarButtonItem').alloc().initWithImage_style_target_action_(ns(ui.Image.named('emj:Bicycle').with_rendering_mode(ui.RENDERING_MODE_ORIGINAL)),0,bb_target,sel('invokeAction:')).autorelease() UIBarButtonItemGroup = ObjCClass('UIBarButtonItemGroup').alloc().initWithBarButtonItems_representativeItem_([UIBarButtonItem],None) tvo = tv.objc_instance tvo.inputAssistantItem().setTrailingBarButtonGroups([UIBarButtonItemGroup]) v.present('sheet') tv.selected_range = (0,0) tv.begin_editing()
-
Dear.cvp
I didn't have a test because I didn't have time to try it.
I'll take a test on the weekend.