Skip to main content

This library allows you to write and save files to the users folder. Useful for when you convert this script to a onefile exe program.

Project description

UserFolder

What is this?

This is a simple library that allows you to read, write and create files within your own folder inside the user folder (C:/User/USER/.python/PACKAGE_ID)

Features

  • Automatically creates the directory.
  • Read and write to files inside the User folder.
  • Includes an uninstall function that will delete all files inside your directory.
  • A function to open the directory or open the file that is inside the directory.

Install

pip install UserFolder

Requirements

Name Descirption
requests Requests is a simple, yet elegant, HTTP library.
uuid UUID object and generation functions (Python 2.3 or higher)

License

MIT License

Examples

Download needed assets

import UserFolder

user = UserFolder.User('com.legopitstop.example') # Create user folder

if user.exists('UserFolder-1.0.2')==False: # Check if folder already exists
    # Download ZIP
    user.download('https://github.com/legopitstop/UserFolder/archive/refs/tags/v1.0.2.zip', 'package.zip')
    # Unarchive ZIP
    user.unarchive('package.zip')

Universal config

import tkinter
import UserFolder
from UserFolder import dialog
from enum import Enum

user = UserFolder.User('com.legopitstop.example') # Create user folder

# Define values
class values(Enum):
    item1 = 'item1'
    item2 = 'item2'
    item3 = 'item3'
    item4 = 'item4'
    item5 = 'item5'

# Create config with section "metadata"
config = UserFolder.Config(section='metadata')

# Register options
config.registerItem('option1', 'value1', str, 'Option1', 'String config item')
config.registerItem('option2', True, bool, 'Option2', 'Boolean config item')
config.registerItem('option3', 1, int, 'Option3', 'Integer config item', from_=0, to=10)
config.registerItem('option4', 1.0, float, 'Option4', 'Float config item', from_=0.0, to=1.0)
config.registerItem('option5', 50, range, 'Option5', 'Range config item')
config.registerItem('option6', values.item1, values, 'Option6', 'Enum config item')

# Tkinter UI
root = tkinter.Tk()
root.title('Main Window')
root.minsize(500, 500)

# Open config dialog when pressed
tkinter.Button(root, text='Open ConfigDialog', command=lambda: dialog.ConfigDialog(parent=root)).pack()

# Open user folder when pressed
tkinter.Button(root, text='Open User Folder', command=user.show).pack()
root.mainloop()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

UserFolder-1.2.0.tar.gz (13.0 kB view details)

Uploaded Source

File details

Details for the file UserFolder-1.2.0.tar.gz.

File metadata

  • Download URL: UserFolder-1.2.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for UserFolder-1.2.0.tar.gz
Algorithm Hash digest
SHA256 e14e5617de0c4943bcc3c0293aa7d376d30d00ff3d336dc208a6c231b06dcf0a
MD5 ce5edfceedd4bdd269615e2ecf672243
BLAKE2b-256 c06b63aa22a81ab17a247e28958676e076bc161f89968a730f7dc82fa1dc6077

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page