GithubHelp home page GithubHelp logo

chogui's Introduction

ChoGUI

ChoGUI is a Python GUI builder based on Tkinter.

Getting Started

To get started, save the 'tkintergui' folder anywhere on your computer and import it properly

project
│   test.py  
│
└───chogui
    | ...
# test.py
import chogui as gui
gui.resizable(True, True)

def testClickFunc(data):
    print("Hello world!")

def testHoveringIn(data):
    print("Hi, mouse cursor")

def testHoveringOut(data):
    print("Bye, cursor")

label = gui.Label()
label.size(0,40,0,15)
label.pos(0,10,0,10)
label.fontfamily("Georgia")
label.fontsize(22)
label.bordersize(4)
label.bordercolor("0000ff")
label.content("Hello World!")
label.onclick(testClickFunc)
label.onhoverin(testHoveringIn)
label.onhoverout(testHoveringOut)
label.hidden(False)
gui.renderall()

gui.finish()

The 'finish' method

You must use the 'finish' method at the end of your code or your program will exit on its own

import chogui as cgui

cgui.finish() # Very important!

Default methods

windowsize(int,int)

Set the size of the window. The first argument is the width, the second argument is the height. It will either size in pixels or percentage of monitor size based on the option set for windowsizemethod() (by default it is pixels)

chogui.windowsize(800,600)

windowsizemethod(int)

Define the method the window will resize. There are currently two options:

  1. By pixels
  2. By monitor percentage
chogui.windowsizemethod(2)
chogui.windowsize(50,50)

fullscreen(bool)

Toggle fullscreen on or off. Fullscreen being enabled will overrule the window size and be automatically set to the max monitor size.

chogui.fullscreen(True)

borderless(bool)

Toggle borderless mode on or off. If borderless mode is turned on, the window will have no border or title bar.

chogui.borderless(True)

title(str)

Set the text displayed in the window's titlebar

chogui.title("Made with ChoGUI")

resizable(bool,bool)

Set whether or not the window can be resized in the X or Y direction

chogui.resizable(False, True) # Window can't be resized left or right, but can be resized up and down

blockwindows(), blockmacos(), blocklinux()

Block usage of your program in that respective operating system

chogui.blocklinux() # Linux users will be forced to quit your program when they open it

Classes

'Label'

A label is a widget that can contain text and has a color and border. It can be positioned anywhere on the screen and given any size, either based on pixels or percentage of window size. All labels start at the top-left of the screen and expand in the opposite directon when its size is changed.

import chogui as cgui

label = cgui.Label()

Methods

pos(int,int,int,int)

Set the position of the label on the canvas. The first argument is for the x location in pixels The second argument is for the x location in percentage The third argument is for the y location in pixels The fourth argument is for the y location in percentage

label.pos(100,7,300,20) # 100 pixels and 7% across the screen, 300 pixels and 20% down the screen

size(int,int,int,int)

Set the size of the element. The first argument is for the width in pixels The second argument is for the width in percentage The third argument is for the height in pixels The fourth argument is for the height in percentage

label.pos(100,7,300,20) # 100 pixels and 7% in width, 300 pixels and 20% in height

color((Hexadecimal Color Code))

Set the color of the label with a hexadecimal color code

label.color('FF00CC')

content(str)

Set the text the label contains. Text always appear at the center of a label

label.content("Hello World!")

bordercolor((Hexadecimal Color Code))

Set the color of the label's border with a hexadecimal color code

label.bordercolor('0000FF')

bordersize(int)

Set the thickness of the label's border in pixels

label.bordersize(3)

fontsize(int)

Set the size of the label's text with an integer

label.fontsize(21)

fontfamily(str)

Set the font family the label's text will be displayed in by the font family's name Do not include spaces! If there are multiple words in the fony family's name, merge the words together.

label.fontfamily("ComicSansMS")

fontcolor((Hexadecimal Color Code))

Set the color of the label's text with a hexadecimal color code

label.fontcolor('FFFF00')

hidden(bool)

Toggle whether or not the label is hidden. Hidden labels cannot be interacted with in any way (hovering, clicking, etc), nor can they be seen at all

label.hidden(False)

onclick(func)

Append a function to the label which it will perform when it is clicked

def test(data):
    print(data, "Hello World!")

label.onclick(test)

onhoverin(func)

Append a function to the label when the mouse cursor hovers into it

def test(data):
    print(data, "Hello, mouse cursor")

label.onhoverin(test)

onhoverout(func)

Append a function to the label when the mouse cursor hovers away from it, after hovering in

def test(data):
    print(data, "Goodbye, mouse cursor")

'Image'

An image is a widget that contains an image file of your choice. This is done using PIP, which supports many image file types, including PNG, JPG, GIF, and BMP. Images can be positioned, resized, given onclick/hover procedures, and given borders.

Images with transprency are not supported. Images with alpha colors and transparency may behave strangely and transparent areas will be filled with a white color.

import chogui as cgui

image = cgui.Image("image.png")

Methods

pos(int,int,int,int)

Set the position of the image on the canvas. The first argument is for the x location in pixels The second argument is for the x location in percentage The third argument is for the y location in pixels The fourth argument is for the y location in percentage

image.pos(100,7,300,20) # 100 pixels and 7% across the screen, 300 pixels and 20% down the screen

size(int,int,int,int)

Set the size of the image. The first argument is for the width in pixels The second argument is for the width in percentage The third argument is for the height in pixels The fourth argument is for the height in percentage

image.pos(100,7,300,20) # 100 pixels and 7% in width, 300 pixels and 20% in height

bordercolor((Hexadecimal Color Code))

Set the color of the image's border with a hexadecimal color code

image.bordercolor('0000FF')

bordersize(int)

Set the thickness of the image's border in pixels

image.bordersize(3)

hidden(bool)

Toggle whether or not the image is hidden. Hidden images cannot be interacted with in any way (hovering, clicking, etc), nor can they be seen at all

image.hidden(False)

onclick(func)

Append a function to the image which it will perform when it is clicked

def test(data):
    print(data, "Hello World!")

image.onclick(test)

onhoverin(func)

Append a function to the image when the mouse cursor hovers into it

def test(data):
    print(data, "Hello, mouse cursor")

image.onhoverin(test)

onhoverout(func)

Append a function to the image when the mouse cursor hovers away from it, after hovering in

def test(data):
    print(data, "Goodbye, mouse cursor")

image.onhoverout(test)

chogui's People

Contributors

josephky avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.