Python3.6 use font awesome icons - python

I am searching how can i use font-awesome icons to a Tkinter python application.
Here is what i tried:
https://fontawesome.com/icons/tree?style=solid
pip3 install fontawesome
Python 3.6.9 (default, May 23 2020, 00:01:58)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import fontawesome as fa
>>> print(fa.icons['tree'])

>>>
I know that i must download icons - map (i do it in the past) but i don't find now how.
Thanks in advance
Edit: Same question before 26 days: FontAwesome with Python

If you want to see actual icons on your shell you need to install fontawesome's font on your computer and configure your terminal emulator to use this font.
Fontawesome the font is a font, but instead of just letters it also got icons.
fontawesome the python library is just dictionary with the icon's name as key and the character as value. But you can see the actual caractere only if you install Fontawesome the font.

Related

pysimplegui popup button_justification problem

According to the documentation of PySimpleGUI, the popup element should have an argument called button_justification, which position the button in 'right' or 'left', or 'center' within the popup window.
When i added button_justification='center' to the popup element in my project it raised the error: popup() got an unexpected keyword argument 'button_justification'. What's the problem?
Image
Not all enhancements added into the PyPI version.
Download from GitHub
There is code in the PySimpleGUI package that upgrades your previously pip installed package to the latest version checked into GitHub.
You can use the commands psgmain to run the test harness or psgupgrade to invoke the GitHub upgrade code.
or, you can call sg.main(), like
d:\>python
Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import PySimpleGUI as sg
>>> sg.main()

where can I find pygame.init() method in the installed pygame directory?

I can't find pygame.init() function. please see what I did.
ckim#chan-ubuntu:~$ python
Python 2.7.12 (default, Nov 12 2018, 14:36:49)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
>>> print (pygame.__file__)
/usr/local/lib/python2.7/dist-packages/pygame/__init__.pyc
>>> pygame.init()
(6, 0)
so I searched under /usr/local/lib/python2.7/dist-packages/pygame but couldn't find the init() source code for module pygame. There I found base.so file which includes init ( checked with nm base.so). So is pygame not installed with all the source codes, some functions and types imlemented in C or C++ and provided by .so files?
Yes, a big part of pygame is written in C.
Here's the source of the init method of the pygame module.
I don't know what the compiled files look like in Linux since I don't have a Linux machine with pygame ready at the moment. But on Windows, you'll find e.g. base.cp37-win32.pyd, which is basically a DLL with the compiled C code.

Python webbrowser - registering browsers on Windows

I'm trying to register the Firefox browser to run on Windows. According to the documentation for Webbrowser, "If the environment variable BROWSER exists, it is interpreted to override the platform default list of browsers, as a os.pathsep-separated list of browsers to try in order". I tried setting it, but it had no impact.
Z:\>SET BROWSER=C:\Program Files (x86)\Mozilla Firefox\firefox.exe %s
Z:\>python3
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (I
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import webbrowser
>>>
>>> webbrowser.open('http://google.com')
True
>>>
webbrowser.get("firefox") doesn't work either
How can I make webbrowser launch Firefox?
You might need to set static envionment viraibles, this you can do in the properties of my computer... Whether or not it will help is for you to figure out (worked over here..).
Another way to do this:
import webbrowser
webbrowser.get("open -a C:\\Program F~\\Mozilla Firefox\\firefox.exe %s")
webbrowser.open('http://google.com')

Endless Syntax Errors for sqlite in terminal

I'm trying to lean sqlite3 and create databases, but I'm having trouble getting started. I go to the Terminal and start things off by typing sqlite3. I get the following prompt:
sqlite>
I installed sqlAcademy and am trying to work through the tutorial, but with examples like:
>>> import sqlalchemy
>>> sqlalchemy.__version__
0.7.0
They appear to be typing in the Terminal, but my code shows an error:
sqlite> import sqlalchemy;
Error: near "import": syntax error
Is there a wrapper I should be using in Terminal so I can type in Python? Do I need to individually write, compile, and run all of the example or is there an easier way?
I know this sounds vague, but I think I'm doing something very obvious wrong. Just too new to know what it is.
That's because you're running in sqlite terminal. The sample code should be run from python's terminal.
To further expand on Demian's answer:
In the terminal type:
$ python
you will get (or similar depending on which version of python you have installed)
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
From there you can enter your import sqlalchemy
Alternatively you can create a python script file (*.py) and put your code in it. Then run run the code by changing to the directory that your files are in, and entering
python filename.py
Hope that helps.

web2py Error :- unable to detect browser

i install a web2py on my machine. i simply click on web2py.exe then it asking for password then it says "unable to detect your browser".
Any help will be appreciable.
This is not an error, it is just a warning message.
This message is being introduced by this line which propose is just to open the web browser automatically.
But, even without webbrowser module you should be able to run web2py and ignore the warning message,
If you are unable to run web2py or having any trouble, please open an issue ticket and web2py developers will look in to it.
The message is coming from here:
def try_start_browser(url):
""" Try to start the default browser """
try:
import webbrowser
webbrowser.open(url)
except:
print 'warning: unable to detect your browser'
You might try the webbrowser.open from a python cli shell to see what the specific exception is. On my (OS X) system:
~ $ python
Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import webbrowser
>>> webbrowser.open('http://stackoverflow.com')
True

Categories