Posts

Showing posts from May, 2021

Creating Standalone Executable from Python

Install the Python Installer pip install pyinstaller Generate an icon for your application from web tool http://tools.dynamicdrive.com/favicon/ Issue the following command pyinstaller --onedir --onefile --name="Demo" --windowed --icon="favicon.ico" "demo.py"

Creating GUI Applications using tkinter

Download the package tk conda install tk pip install tk # create a new frame from tkinter import * root = Tk() root.geometry("600x250") root.mainloop() # Using Label in Frame from tkinter import * root= Tk() root.geometry("600x250") my_text= Label(root, text= "This is a New Line Text", font=('Helvetica bold', 16)) my_text.pack(pady=30) root.mainloop() # Adding Buttons from tkinter import * from tkinter import ttk win= Tk() win.geometry("400x300") def save():    print("Saved") cmdsave= ttk.Button(win, text="Save",command=lambda:save()) cmdsave.pack() win.mainloop() # Using Images from tkinter import * root= Tk() root.geometry("750x280") canvas= Canvas(root, width=300, height=300) logo = PhotoImage(file='logo.png') canvas.create_image((200, 140), image=logo) canvas.pack() root.mainloop() # Sample GUI Application from tkinter import * fields = ('Annual Rate', 'Number of Payments', 'Lo...

Calling Python Functions from Java

Java Program import org.python.core.PyInstance;   import org.python.util.PythonInterpreter;   class PythonJava  {      PythonInterpreter interpreter = null;      public PythonJava()      {         PythonInterpreter.initialize(System.getProperties(),System.getProperties(), new String[0]);         this.interpreter = new PythonInterpreter();      }      void execfile( final String fileName )      {         this.interpreter.execfile(fileName);      }      PyInstance createClass( final String className, final String opts )      {         return (PyInstance) this.interpreter.eval(className + "(" + opts + ")");      }      public static void main( String ...