Hi expert,
I want to access to the Bluetooth headset's button action(Pause, Last,Next). how can I get this using Pythonista?
Best regards!
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.
Hi expert,
I want to access to the Bluetooth headset's button action(Pause, Last,Next). how can I get this using Pythonista?
Best regards!
@cvp It worked for me, thank you so much!
Hi All,
I'm developing a dictionary app for my English test.I want to access the definition of the English word. so
I just add the following code to the button_tapped_event(button_details_tapped) of my project,but when the Apple standard language dictionaries appear, I can not let the sub-view disappear by tapping "Done" button in the sub-view. Can someone help me solve this problem?
The code that I used is:
Coding: utf-8
from objc_util import ObjCClass, UIApplication, CGSize, on_main_thread,ObjCInstance
import sys
import ui
UIReferenceLibraryViewController = ObjCClass('UIReferenceLibraryViewController')
back= ui.View()
back.background_color='gray'
back.name = 'Dictionary'
back.present('full_screen',hide_title_bar=False)
input = 'word'
referenceViewController = UIReferenceLibraryViewController.alloc().initWithTerm_(input)
ObjCInstance(back).addSubview_(referenceViewController.view())
* list item
rootVC = UIApplication.sharedApplication().keyWindow().rootViewController()
tabVC = rootVC.detailViewController()
referenceViewController.setTitle_('Definition: {0}{1}{0}'.format('\'', input))
referenceViewController.setPreferredContentSize_(CGSize(540, 540))
referenceViewController.setModalPresentationStyle_(2)
#tabVC.addTabWithViewController_(referenceViewController)
tabVC.presentViewController_animated_completion_(referenceViewController, True, None)
This is part of my project's code:
def button_details_tapped(sender):
global g_db_element
global debug
global v
try:
label_englishshow.text = g_db_element
UIReferenceLibraryViewController = ObjCClass('UIReferenceLibraryViewController')
UIViewController = ObjCClass('UIViewController')
input = g_db_element
methods = [fun1,fun2,fun3]
protocols=['ARSCNViewDelegate']
referenceViewController = create_objc_class('referenceViewController',UIViewController,methods=methods,protocols=protocols)
referenceViewController = UIReferenceLibraryViewController.alloc().initWithTerm_(input).autorelease()
ObjCInstance(v).addSubview_(referenceViewController.view())
rootVC = UIApplication.sharedApplication().keyWindow().rootViewController()
tabVC = rootVC.detailViewController()
referenceViewController.setTitle_('Definition: {0}{1}{0}'.format('\'', input))
referenceViewController.setPreferredContentSize_(CGSize(540, 540))
referenceViewController.setModalPresentationStyle_(2)
#tabVC.addTabWithViewController_(referenceViewController)
tabVC.presentViewController_animated_completion_(referenceViewController, True, None)
except Error:
print(Error)
def button_pronounce_tapped(sender):
global g_db_element
try:
speech.say(g_db_element,'en-UK',0.5)
except Error:
print(Error)
def textfield_wordtypein_tapped(sender):
global g_db_element
global debug
try:
label_englishshow.text = g_db_element
if debug == True:
print("textfield_wordtypein_tapped function")
except Error:
print(Error)
def textfield_chapter_tapped(sender):
global g_db_chapter
try:
g_db_chapter = int(sender.text)
except Error:
print(Error)
def textfield_section_tapped(sender):
global g_db_section
try:
g_db_section = int(sender.text)
except Error:
print(Error)
v = ui.load_view()
label_englishshow = v['label_englishshow']
label_chinese_meaningshow = v['label_chinese&meaningshow']
textfield_wordtypein = v['textfield_wordtypein']
textfield_chapter = v['textfield_chapter']
textfield_section = v['textfield_section']
textfield_chapter.text = str(g_db_chapter)
textfield_section.text = str(g_db_section)
#get the row length of database
conn = sqlite3.connect('wanglu_linguistic_material.db')
cursor = conn.cursor()
cursor.execute("select * from wanglu_linguistic_material")
results = cursor.fetchall()
G_DB_ROW_LENGTH = len(results)
conn.close
#end
v.present('sheet')
The whole code is in github:
https://github.com/alexsun8373/pythonista_wanglu_linguistic_material/blob/master/wanglu_linguistic_material.py
Best regards!