vcard
parent
8efc69cbfd
commit
ee9967a339
|
|
@ -0,0 +1,198 @@
|
|||
countries = [
|
||||
"Afghanistan",
|
||||
"Albania",
|
||||
"Algeria",
|
||||
"Andorra",
|
||||
"Angola",
|
||||
"Antigua and Barbuda",
|
||||
"Argentina",
|
||||
"Armenia",
|
||||
"Australia",
|
||||
"Austria",
|
||||
"Azerbaijan",
|
||||
"The Bahamas",
|
||||
"Bahrain",
|
||||
"Bangladesh",
|
||||
"Barbados",
|
||||
"Belarus",
|
||||
"Belgium",
|
||||
"Belize",
|
||||
"Benin",
|
||||
"Bhutan",
|
||||
"Bolivia",
|
||||
"Bosnia and Herzegovina",
|
||||
"Botswana",
|
||||
"Brazil",
|
||||
"Brunei",
|
||||
"Bulgaria",
|
||||
"Burkina Faso",
|
||||
"Burundi",
|
||||
"Cambodia",
|
||||
"Cameroon",
|
||||
"Canada",
|
||||
"Cape Verde",
|
||||
"Central African Republic",
|
||||
"Chad",
|
||||
"Chile",
|
||||
"China",
|
||||
"Colombia",
|
||||
"Comoros",
|
||||
"Congo, Republic of the",
|
||||
"Congo, Democratic Republic of the",
|
||||
"Costa Rica",
|
||||
"Cote d'Ivoire",
|
||||
"Croatia",
|
||||
"Cuba",
|
||||
"Cyprus",
|
||||
"Czech Republic",
|
||||
"Denmark",
|
||||
"Djibouti",
|
||||
"Dominica",
|
||||
"Dominican Republic",
|
||||
"East Timor (Timor-Leste)",
|
||||
"Ecuador",
|
||||
"Egypt",
|
||||
"El Salvador",
|
||||
"Equatorial Guinea",
|
||||
"Eritrea",
|
||||
"Estonia",
|
||||
"Ethiopia",
|
||||
"Fiji",
|
||||
"Finland",
|
||||
"France",
|
||||
"Gabon",
|
||||
"The Gambia",
|
||||
"Georgia",
|
||||
"Germany",
|
||||
"Ghana",
|
||||
"Greece",
|
||||
"Grenada",
|
||||
"Guatemala",
|
||||
"Guinea",
|
||||
"Guinea-Bissau",
|
||||
"Guyana",
|
||||
"Haiti",
|
||||
"Honduras",
|
||||
"Hungary",
|
||||
"Iceland",
|
||||
"India",
|
||||
"Indonesia",
|
||||
"Iran",
|
||||
"Iraq",
|
||||
"Ireland",
|
||||
"Israel",
|
||||
"Italy",
|
||||
"Jamaica",
|
||||
"Japan",
|
||||
"Jordan",
|
||||
"Kazakhstan",
|
||||
"Kenya",
|
||||
"Kiribati",
|
||||
"Korea, North",
|
||||
"Korea, South",
|
||||
"Kosovo",
|
||||
"Kuwait",
|
||||
"Kyrgyzstan",
|
||||
"Laos",
|
||||
"Latvia",
|
||||
"Lebanon",
|
||||
"Lesotho",
|
||||
"Liberia",
|
||||
"Libya",
|
||||
"Liechtenstein",
|
||||
"Lithuania",
|
||||
"Luxembourg",
|
||||
"Macedonia",
|
||||
"Madagascar",
|
||||
"Malawi",
|
||||
"Malaysia",
|
||||
"Maldives",
|
||||
"Mali",
|
||||
"Malta",
|
||||
"Marshall Islands",
|
||||
"Mauritania",
|
||||
"Mauritius",
|
||||
"Mexico",
|
||||
"Micronesia, Federated States of",
|
||||
"Moldova",
|
||||
"Monaco",
|
||||
"Mongolia",
|
||||
"Montenegro",
|
||||
"Morocco",
|
||||
"Mozambique",
|
||||
"Myanmar (Burma)",
|
||||
"Namibia",
|
||||
"Nauru",
|
||||
"Nepal",
|
||||
"Netherlands",
|
||||
"New Zealand",
|
||||
"Nicaragua",
|
||||
"Niger",
|
||||
"Nigeria",
|
||||
"Norway",
|
||||
"Oman",
|
||||
"Pakistan",
|
||||
"Palau",
|
||||
"Panama",
|
||||
"Papua New Guinea",
|
||||
"Paraguay",
|
||||
"Peru",
|
||||
"Philippines",
|
||||
"Poland",
|
||||
"Portugal",
|
||||
"Qatar",
|
||||
"Romania",
|
||||
"Russia",
|
||||
"Rwanda",
|
||||
"Saint Kitts and Nevis",
|
||||
"Saint Lucia",
|
||||
"Saint Vincent and the Grenadines",
|
||||
"Samoa",
|
||||
"San Marino",
|
||||
"Sao Tome and Principe",
|
||||
"Saudi Arabia",
|
||||
"Senegal",
|
||||
"Serbia",
|
||||
"Seychelles",
|
||||
"Sierra Leone",
|
||||
"Singapore",
|
||||
"Slovakia",
|
||||
"Slovenia",
|
||||
"Solomon Islands",
|
||||
"Somalia",
|
||||
"South Africa",
|
||||
"South Sudan",
|
||||
"Spain",
|
||||
"Sri Lanka",
|
||||
"Sudan",
|
||||
"Suriname",
|
||||
"Swaziland",
|
||||
"Sweden",
|
||||
"Switzerland",
|
||||
"Syria",
|
||||
"Taiwan",
|
||||
"Tajikistan",
|
||||
"Tanzania",
|
||||
"Thailand",
|
||||
"Togo",
|
||||
"Tonga",
|
||||
"Trinidad and Tobago",
|
||||
"Tunisia",
|
||||
"Turkey",
|
||||
"Turkmenistan",
|
||||
"Tuvalu",
|
||||
"Uganda",
|
||||
"Ukraine",
|
||||
"United Arab Emirates",
|
||||
"United Kingdom",
|
||||
"United States of America",
|
||||
"Uruguay",
|
||||
"Uzbekistan",
|
||||
"Vanuatu",
|
||||
"Vatican City (Holy See)",
|
||||
"Venezuela",
|
||||
"Vietnam",
|
||||
"Yemen",
|
||||
"Zambia",
|
||||
"Zimbabwe",
|
||||
]
|
||||
|
|
@ -4,9 +4,9 @@ import io
|
|||
import os
|
||||
|
||||
from modules import script_callbacks
|
||||
from scripts import constants
|
||||
from PIL import Image
|
||||
import segno
|
||||
from segno import helpers
|
||||
|
||||
def generate_text(text, is_micro):
|
||||
qrcode = segno.make(text, micro=is_micro)
|
||||
|
|
@ -18,13 +18,19 @@ def generate_wifi(ssid, password, security):
|
|||
if security == "None":
|
||||
password = security = None
|
||||
|
||||
qrcode = helpers.make_wifi(ssid=ssid, password=password, security=security)
|
||||
qrcode = segno.helpers.make_wifi(ssid=ssid, password=password, security=security)
|
||||
out = io.BytesIO()
|
||||
qrcode.save(out, scale=5, kind='png')
|
||||
return Image.open(out)
|
||||
|
||||
def generate_geo(latitude, longitude):
|
||||
qrcode = helpers.make_geo_data(latitude, longitude)
|
||||
qrcode = segno.helpers.make_geo(latitude, longitude)
|
||||
out = io.BytesIO()
|
||||
qrcode.save(out, scale=5, kind='png')
|
||||
return Image.open(out)
|
||||
|
||||
def generate_vcard(name, displayname, nickname, street, city, region, zipcode, country, birthday, email, phone, fax):
|
||||
qrcode = segno.helpers.make_vcard(name=name, displayname=displayname, nickname=nickname, street=street, city=city, region=region, zipcode=zipcode, country=country, birthday=birthday, email=email, phone=phone, fax=fax)
|
||||
out = io.BytesIO()
|
||||
qrcode.save(out, scale=5, kind='png')
|
||||
return Image.open(out)
|
||||
|
|
@ -47,13 +53,29 @@ def on_ui_tabs():
|
|||
latitude = gr.Number(0, label="Latitude")
|
||||
longitude = gr.Number(0, label="Longitude")
|
||||
button_generate_geo = gr.Button("Generate", variant="primary")
|
||||
|
||||
with gr.Tab("vCard"):
|
||||
name = gr.Text(label="Name")
|
||||
displayname = gr.Text(label="Display Name")
|
||||
nickname = gr.Text(label="Nickname")
|
||||
address = gr.Text(label="Address")
|
||||
with gr.Row():
|
||||
city = gr.Text(label="City")
|
||||
state = gr.Text(label="State")
|
||||
with gr.Row():
|
||||
zipcode = gr.Text(label="ZIP Code")
|
||||
country = gr.Dropdown(label="Country", choices=constants.countries)
|
||||
birthday = gr.Text(label="Birthday")
|
||||
email = gr.Text(label="email")
|
||||
phone = gr.Text(label="Phone")
|
||||
fax = gr.Text(label="Fax")
|
||||
button_generate_vcard = gr.Button("Generate", variant="primary")
|
||||
with gr.Column():
|
||||
output = gr.Image(interactive=False, show_label=False).style(height=480)
|
||||
|
||||
button_generate_text.click(generate_text, [text, micro_code], output, show_progress=False)
|
||||
button_generate_wifi.click(generate_wifi, [ssid, password, security], output, show_progress=False)
|
||||
button_generate_geo.click(generate_wifi, [latitude, longitude], output, show_progress=False)
|
||||
button_generate_vcard.click(generate_vcard, [name, displayname, nickname, address, city, state, zipcode, country, birthday, email, phone, fax], output, show_progress=False)
|
||||
|
||||
return [(ui_component, "QR Code", "qrcode_tab")]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue