Jump to content

Need help with GUI tkinter (Beginner)

Sharif
Go to solution Solved by Guest,
2 hours ago, Doctor_GLaDOS said:

MySQL

MySQL is love. MySQL is life.

 

This summer to get a bit more invested in programming, decided to finally pick up a little project of my own.

I usually have all my expenses down on an excel sheet, to make sure I break even at minimum lol 

 

Which gave me an idea for my first project of my own. a GUI expanse calculator.

Decided to go with Python, mainly because I feel like there is more doing with python than the little time I spent with java, with more time spent figuring out the peculiar syntax, I want this project to be a good practice getting comfortable with using classes, storing files, reading from them to put on, creating a decent UI, all that. Feel free to snap me out of the excel sheet way I am approaching this, and if there is a better way to make this. 

 

TLDR

The reason I made this post, I am unsure what is considered a proper way to store weekly expenditure, a list? How do I go on storing them permanently, so that the next time I open it, the previous data is still there? What's the proper way of storing them so that I can easily read them again, and put them on a table on the final app. 

 

Some pointers would be appreciated, not looking for someone to tell me to do xyz, more like you'll need this and that, look into that and that, play around with them kinda thing. 

I hope I wasn't too obscure, any help is appreciated. :)

Current system - ThinkPad Yoga 460

ExSystems

Spoiler

Laptop - ASUS FX503VD

|| Case: NZXT H440 ❤️|| MB: Gigabyte GA-Z170XP-SLI || CPU: Skylake Chip || Graphics card : GTX 970 Strix || RAM: Crucial Ballistix 16GB || Storage:1TB WD+500GB WD + 120Gb HyperX savage|| Monitor: Dell U2412M+LG 24MP55HQ+Philips TV ||  PSU CX600M || 

 

Link to comment
Share on other sites

Link to post
Share on other sites

It depends on how you want to classify your data. 

Some ways are:

list 

list of classes

interfacing with a database like sql. 

 

For saving data, you could adopt a file format, create your own or use a database program like SQL.

 

The best & worst part about programming is that it’s all up to you. 

 

Edit:

personally i find HTML & php to be the best for working with SQL, because I think web applications are the easiest to work with when dealing with databases. However ALL popular languages have a way to interact with SQL. 

 

Except maybe Lua, but I’m sure someone wrote a library. 

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, fpo said:

It depends on how you want to classify your data. 

Some ways are:

list 

list of classes

interfacing with a database like sql. 

 

For saving data, you could adopt a file format, create your own or use a database program like SQL.

 

The best & worst part about programming is that it’s all up to you. 

 

Edit:

personally i find HTML & php to be the best for working with SQL, because I think web applications are the easiest to work with when dealing with databases. However ALL popular languages have a way to interact with SQL. 

 

Except maybe Lua, but I’m sure someone wrote a library. 

So when you mean list of classes, do you mean an individual class for each list (say for each week of expenses tracked), week 2 will have another class with its respective functions I choose to put in there? 

 

SQL is something I don't know anything about, I can perhaps improve the app in version 2, with the help of that instead, but that's something for later. I am really looking to make something simple as possible, just to help with my understanding the concept and slowly make it better over time. 

Current system - ThinkPad Yoga 460

ExSystems

Spoiler

Laptop - ASUS FX503VD

|| Case: NZXT H440 ❤️|| MB: Gigabyte GA-Z170XP-SLI || CPU: Skylake Chip || Graphics card : GTX 970 Strix || RAM: Crucial Ballistix 16GB || Storage:1TB WD+500GB WD + 120Gb HyperX savage|| Monitor: Dell U2412M+LG 24MP55HQ+Philips TV ||  PSU CX600M || 

 

Link to comment
Share on other sites

Link to post
Share on other sites

10 minutes ago, Sharif said:

So when you mean list of classes, do you mean an individual class for each list (say for each week of expenses tracked), week 2 will have another class with its respective functions I choose to put in there? 

Make a base class of what your data should contain. IE


MoneyClass:

integer spentOnNeeds #food, gas

integer spentOnWants #video Games 

Date day #the day this was spent

string additional notes #i got sick & went to the doctor

now your data is more organized. You can write some methods for this class like “total spent” returning money needed plus money wants. 

You could see “why did I spend so much money this day?” And call the method that prints the additional notes. 

 

Classes simply hold a collection of data. Having a list of classes makes it easy to have a lot of them easily accessible. 

 

ListName[5].CheckMoneySpent()

ListName[5].PrintAdditionalNotes()

ListName[3].CheckMoneySpent()

ListName[3].PrintAdditionalNotes()

 

output:

“$300”

“I bought the new video game I wanted.”

”$100”

”N/A NO NOTES WERE ADDED.”

 

10 minutes ago, Sharif said:

SQL is something I don't know anything about, I can perhaps improve the app in version 2, with the help of that instead, but that's something for later. I am really looking to make something simple as possible, just to help with my understanding the concept and slowly make it better over time. 

You’ll probably just want to write the program from the beginning at that point. 

1. You’ll be more experienced & write it better. 

2. It may be better to write it differently as it will be working differently. 

Not to say you might end up being able to adapt the old program and be perfectly fine. You may very well be capable. 

Link to comment
Share on other sites

Link to post
Share on other sites

@Sharif I also second the suggestion of making it a web app, skill wise its more valuable than desktop development :)

 

However, you shouldn't structure a class like that even for a simple app like yours, as a beginner you must try to follow best practices, bad coding practices stick to people for a long time.

Spoiler

MoneyClass:

integer spentOnNeeds #food, gas

integer spentOnWants #video Games 

Date day #the day this was spent

string additional notes #i got sick & went to the doctor

 

1) Pick any language and learn how to use it for back-end development

2) Database basics should take a couple hours through YouTube tutorials (I suggest MySQL)

3) Then Google or YouTube your way into how to connect your web application to your database

 

That's pretty much it, the first point is the most time consuming :D

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Hi P said:

@Sharif I also second the suggestion of making it a web app, skill wise its more valuable than desktop development :)

 

However, you shouldn't structure a class like that even for a simple app like yours, as a beginner you must try to follow best practices, bad coding practices stick to people for a long time.

  Reveal hidden contents


MoneyClass:

integer spentOnNeeds #food, gas

integer spentOnWants #video Games 

Date day #the day this was spent

string additional notes #i got sick & went to the doctor

 

1) Pick any language and learn how to use it for back-end development

2) Database basics should take a couple hours through YouTube tutorials (I suggest MySQL)

3) Then Google or YouTube your way into how to connect your web application to your database

 

That's pretty much it, the first point is the most time consuming :D

I am currently leaning towards just storing all the expenses in a list and append anything new to that list, the adding, removing, will be all done in one class, because if I remember the theory right, they should all be together since they are related. There is a fancy jargon for this I am forgetting. 

2 hours ago, fpo said:

Make a base class of what your data should contain. IE

 


MoneyClass:

integer spentOnNeeds #food, gas

integer spentOnWants #video Games 

Date day #the day this was spent

string additional notes #i got sick & went to the doctor

 

now your data is more organized. You can write some methods for this class like “total spent” returning money needed plus money wants. 

You could see “why did I spend so much money this day?” And call the method that prints the additional notes. 

 

Classes simply hold a collection of data. Having a list of classes makes it easy to have a lot of them easily accessible. 

 

ListName[5].CheckMoneySpent()

ListName[5].PrintAdditionalNotes()

ListName[3].CheckMoneySpent()

ListName[3].PrintAdditionalNotes()

 

output:

“$300”

“I bought the new video game I wanted.”

”$100”

”N/A NO NOTES WERE ADDED.”

 

You’ll probably just want to write the program from the beginning at that point. 

1. You’ll be more experienced & write it better. 

2. It may be better to write it differently as it will be working differently. 

Not to say you might end up being able to adapt the old program and be perfectly fine. You may very well be capable. 

 

I gave in and decided to properly look up SQL than just it's full form.....it horribly reminds me of MS access from back in high school, so I then looked up MySQL, it seems like another similar app, but I am dealing with the data using MS access in particular at the time (I knew absolutely zero about programming back then), but played around with the filtering, sorting, creating wonko exports of sort depending on the question, but how does something like that connect to a programming language like Python? 

 

Edit

If I can create fields using python itself, does that mean I can somehow use SQL command inside of python? and can I keep this offline? (I actually plan on using this app at the end of the day, and I don't trust myself one bit, to be connected to the internet, plus I don't really need it to be) 

Current system - ThinkPad Yoga 460

ExSystems

Spoiler

Laptop - ASUS FX503VD

|| Case: NZXT H440 ❤️|| MB: Gigabyte GA-Z170XP-SLI || CPU: Skylake Chip || Graphics card : GTX 970 Strix || RAM: Crucial Ballistix 16GB || Storage:1TB WD+500GB WD + 120Gb HyperX savage|| Monitor: Dell U2412M+LG 24MP55HQ+Philips TV ||  PSU CX600M || 

 

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, Sharif said:

If I can create fields using python itself, does that mean I can somehow use SQL command inside of python?

You could if you want to, but I personally lean towards ORMs, I can't suggest any for Python as I don't use that language

 

3 hours ago, Sharif said:

and can I keep this offline?  I don't trust myself one bit, to be connected to the internet

Yes, pretty much you would have to manually open the ports for it to be online, so just skip doing that part

Link to comment
Share on other sites

Link to post
Share on other sites

I'm actually making my own Tkinter program.

To use MySQL you need to first install mysql python addon, than:

from tkinter import *
mydb = mysql.connector.connect(
  host = "localhost",
  user=  "root",
  password = "",
  database = "db"
)

My tips for your project would be to start with grid() instead of pack() because it will give you a head start in making your app both work and look not terrible. Also make sure you complete your logic first before you start adding any visual flare.

Use this website  for allTkinter classes you might need for your project.

Last advice is to use Frame() instead of dumping all labels into the main window, because otherwise when you try to grid_forget() them they will glitch!

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, Doctor_GLaDOS said:

MySQL

MySQL is love. MySQL is life.

 

Link to comment
Share on other sites

Link to post
Share on other sites

7 hours ago, Doctor_GLaDOS said:

I'm actually making my own Tkinter program.

To use MySQL you need to first install mysql python addon, than:


from tkinter import *
mydb = mysql.connector.connect(
  host = "localhost",
  user=  "root",
  password = "",
  database = "db"
)

My tips for your project would be to start with grid() instead of pack() because it will give you a head start in making your app both work and look not terrible. Also make sure you complete your logic first before you start adding any visual flare.

Use this website  for allTkinter classes you might need for your project.

Last advice is to use Frame() instead of dumping all labels into the main window, because otherwise when you try to grid_forget() them they will glitch!

I was thinking of using pack, mainly because I heard someone in some video talk about it being the most flexible, did I get the wrong idea?

Is it a bad practice to be using multiple frames to sort things around the window?

Is there such a thing as too many separate labels, can I just think of them as adding another text here and there, or would that be bad practice? 

5 hours ago, fpo said:

MySQL is love. MySQL is life.

 

You guys convinced me at this point, also if memory serves me right from MS access, these SQL programs can get really powerful if you know how to play around with all the options...also intimidating for beginners like me. 

 

22 hours ago, Hi P said:

You could if you want to, but I personally lean towards ORMs, I can't suggest any for Python as I don't use that language

 

Yes, pretty much you would have to manually open the ports for it to be online, so just skip doing that part

Perfect, it'll allow me to play around with SQL, hopefully it isn't that intimidating thing anymore by end of this month!

Current system - ThinkPad Yoga 460

ExSystems

Spoiler

Laptop - ASUS FX503VD

|| Case: NZXT H440 ❤️|| MB: Gigabyte GA-Z170XP-SLI || CPU: Skylake Chip || Graphics card : GTX 970 Strix || RAM: Crucial Ballistix 16GB || Storage:1TB WD+500GB WD + 120Gb HyperX savage|| Monitor: Dell U2412M+LG 24MP55HQ+Philips TV ||  PSU CX600M || 

 

Link to comment
Share on other sites

Link to post
Share on other sites

On 6/13/2020 at 4:25 AM, Doctor_GLaDOS said:

For Python (non tkinter) and MySQL use this: https://www.w3schools.com/

w3schools is a GREAT resource for when you need an answer on the fly, but there are better resources if you want to learn a programming language from scratch.

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, steelo said:

w3schools is a GREAT resource for when you need an answer on the fly, but there are better resources if you want to learn a programming language from scratch.

That's me googling everything instead lol

Guess that's not smart to rely on multiple sources 

Current system - ThinkPad Yoga 460

ExSystems

Spoiler

Laptop - ASUS FX503VD

|| Case: NZXT H440 ❤️|| MB: Gigabyte GA-Z170XP-SLI || CPU: Skylake Chip || Graphics card : GTX 970 Strix || RAM: Crucial Ballistix 16GB || Storage:1TB WD+500GB WD + 120Gb HyperX savage|| Monitor: Dell U2412M+LG 24MP55HQ+Philips TV ||  PSU CX600M || 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×