Adding Indicators cont'd - Tkinter tutorial Python 3.4 part 16

sentdex · Beginner ·🛠️ AI Tools & Apps ·11y ago

Key Takeaways

The video demonstrates how to add indicators to a GUI using Tkinter, including RSI and MACD calculations, and how to create pop-up messages for user input and validation. It also covers GUI development in Python 3.4 and chart customization.

Full Transcript

hey guys what's going on welcome to the 16th Python with tkinter in a actual creation of a program tutorial video series in this video what we're doing is actually adding the functions that we're calling in some of our menu items so that's add top indicator middle indicator and bottom indicator so let's go ahead and get started so to start we'll do add top man Skype patrol and add top indicator and we'll just say what and what is going to be like what indicator are we adding and then we're going to go ahead and global top indicator and then we're also going to global again that counter so if anybody changes the indicator again we don't want to wait maybe 30 seconds we want to want to issue that a force update right now so that's that now we're going to kind of throw in some conditionals here so for example if the data pace equals a tick so if we're watching tick data we're not going to be adding RSI or MACD and all that there's no real reason for that it's going to be really wild so we're just going to throw a pop-up message and we're gonna have this pop-up message say indicators in tick data not available easy enough subsequently if what equals none if what equals none we're just a top indicator equals what basically so that will equal none again so if that's the case I'll leave what and then we're going to set that counter to 9000 which will force an update and we'll basically remove the indicator if from the graph next we're going to say if and actually we're gonna go ahead and make that an elephant Lee that's a problem that has been a problem since the original program to update that and get help anyway if Elif and then I guess this could be really else actually let's see now I really need to be knowledge so if L if what equals I sigh then we want it to be a relative strength index so if that's the case RSI we're going to call it's our side cue for like basically like a question so when the user chooses RSI it's not really as simple as like okay I want RSI done okay so an RSI has a question of how many periods of time are we considering here so generally an RSI is a period of 14 so say you're you're you're looking at a month month worth of data when you are let's say you're looking at nine months of data okay and you apply an RSI relative strength index generally it's going to be a 14 days window per RSI calculation but some people might want to do 22 or five or whatever and so you want the user to be able to change their minds so we're going to be our s IQ for our site question it's going to be a little window here and so we TK TK very similar to or pop up kind of idea that we were using and then we're gonna say RSI q dot WM title and this will be periods okay so this is gonna be like a pop-up message that are a pop-up window rather it is like okay you've chosen RSI how many periods do you want this art side to be so RSI set the window title the periods and then we're going to pose the question to our user and that will be basically we're going to make a label equals ttk dot and capital l label and then where is this going it's going to the RSI Q and then the text to our user will say um choose how many periods you want each RSI calculation to consider um and let's see that'll do for now we'll keep that so that's our label choose how many period you want to each RSI calculation to consider and then we'll do label dot pack and again we'll say side equals top because we're going to put a button below it fill equals x and then pad Y Patty equals 10 now we're going to go e equals ttk let's fix this e equals ttk a period entry so this is like an entry widget for tkinter and then that's for the RSI Q window and we're going to say you could have it be blank but we actually we're going to kind of we'd like it to be there to be a default values and soleko might not even know like what would be a good number so they might guess and throw in a really bad number so we'll just insert and also some people might choose to go the default is typically 14 so some people might just want the default so we're going to go ahead and insert at the zeroth place 14 just the number 14 will be inserted and then we'll say e dot Pak easy enough and then we're going to set the focus focus set on the basically what is filled in two into here so now now we're going to do yeah define callback and then we're going to global top indicator and then global dat counter as usual now we're going to use a get operation here for so periods periods a equals e get so it's going to get what was put in to the focused a dot insert basically which is an entry widget so it's going to get whatever was typed in there and then we're going to say group equals an empty list for now and now we're going to say group dot append and to that we're and append RSI because that's what the user chose and then we're also going to do group dot append periods and then we're going to say the top indicator equals group now so that's going to be RSI comma 14 will be what is stored under top indicator now we're going to set that counter to 9,000 to force an update and then we're going to say we're going to go ahead and print to console um set top indicator to an N comma group like that and finally once we've done that we don't need our window anymore so we're just going to do RSI q dot destroy so as soon as they basically enter something it's going to run this callback as you'll see in just a second and then as soon as everything's done it's just going to destroy the window so actually hitting okay really it's going to run callback but it's really just destroying the window at the end of the day when it's resetting a value so now we're going to go ahead and do B for button equals T TK capital B for button where's that button going it's going to RSI q what is the text on that button it will be submit and then the width of that button will be 10 and the command that button commands callback finally be dot pack and then we'll go TK main loop empty parameters and then um that's for RSI because RSI has parameters that we're going to allow the users set now we're going to say MACD so this was L if RSI so now we need a new Elif so that's if it's RSI now L if what equals MACD : let's global top indicator global dat counter then we're just going to say this one's a lot easier indicator top indicate or equals MACD and then we're going to say dat counter equals 9000 so in this case this is much easier we could allow them generally um it's like 24 12 and 9 I want to say or 22:12 men I can't I'm not able to think of it right now but it's like twelve and nine I think is the second two values generally most people use the default if MACD I've never really heard anybody changes it but in the future it would be kind of nice to allow man it's driving me nuts oh no the three values but anyways there's three typical values but it would be nice to let the user change them but as you can say see it's kind of a pain that took us to do it but eventually we will let the user change them so that's it for change you know basically add a top indicator so so we let's go ahead and run this and see if anything goes wrong because it very well may invalid syntax somewhere if data pace one equals that's a syntax error that would be an assignment operator we want to comparison operator let's try again okay agree top indicator RSI pops up default 14 periods mid and then we say okay set top indicator to our side 14 no problem awesome um and then if it's what it says it sets it to none and if it's MACD it sets it to MACD no problem okay so where am I I'm over here let's go ahead and exit out of this come over here to our shell like so this and the middle indicator is going to take us a little bit but let's go ahead and and got enough time in this one I guess we're up ten minutes at the moment but that's okay we'll just copy this and this is this is what really pains me to do in the future we will fix this I promise hopefully this isn't bothering everyone as much as it bothers me but copy that entire function post and we're going to come up here instead of add top indicator add bottom indicator global not top indicator global bottom indicator that's that that and actually let's go ahead is it I can't member if I capitalized or lower yeah I did lowercase it actually so copy that come back down here to bottom indicator that's bottom indicator there so global bottom with the lowercase B I capitalized it and then everywhere you see indicator bottom indicator this should all be the same type indicator bottom indicator top indicator nope bottom indicator top indicator nope bottom bottom okay let's save and run that real quick and see how we did so bottom indicator RSI pops up fabulous and oh we need to change the text but it did most likely set the bottom indicator but let's see set top indicator to now set bottom indicator to group okay save that and we're good and now what we need to do is we need to do the middle indicator and I think I'll save that for the next videos this one's a little bit longer and it's not as simple as this was so anyways again sorry for the copy and paste of that function we'll we'll fix that feel free to some people say I should give more challenges in the video so challenge combine these two functions and set it just should just be add you know indicator and then really we should we should combine all of the indicators and then you know you've got what in the comma where you know you should have something like that so maybe we'll do that in the future but till then challenge so anyway um so that's at next video we're going to add that middle indicator so stay tuned for that if you guys have any questions or comments please feel free to leave them below otherwise I was always thanks for watching thanks for all the support and subscriptions and until next time

Original Description

Tkinter GUI Tutorial Playlist: http://www.youtube.com/playlist?list=PLQVvvaa0QuDclKx-QpC9wntnURXVJqLyk Adding indicator options to our GUI. http://seaofbtc.com http://sentdex.com http://hkinsley.com https://twitter.com/sentdex Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from sentdex · sentdex · 0 of 60

← Previous Next →
1 Matplotlib Python Tutorial Part 1: Basics and your first Graph!
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
2 Python Encryption Tutorial with PyCrypto
Python Encryption Tutorial with PyCrypto
sentdex
3 Python's Logging Function
Python's Logging Function
sentdex
4 wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
5 wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
6 wxPython Programming Tutorial 3: Menu Bar and Menu Button
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
7 wxPython Programming Tutorial 4: Panels
wxPython Programming Tutorial 4: Panels
sentdex
8 wxPython Programming Tutorial 5: User Input Saved To Variables
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
9 wxPython Programming Tutorial 6: Multiple Choice Input
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
10 wxPython Programming Tutorial 7: Adding Static Text and Colors
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
11 wxPython Programming Tutorial 8: Custom Button Images
wxPython Programming Tutorial 8: Custom Button Images
sentdex
12 wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
13 Basic PHP Tutorial 13: Multi-dimensional Array
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
14 Basic PHP Tutorial 15: Functions and Global Variables
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
15 Basic PHP Tutorial 12: Associative Array
Basic PHP Tutorial 12: Associative Array
sentdex
16 Basic PHP Tutorial 14: Foreach loop
Basic PHP Tutorial 14: Foreach loop
sentdex
17 Basic PHP Tutorial 16: Include and Require
Basic PHP Tutorial 16: Include and Require
sentdex
18 Basic PHP Tutorial 7: Assignment, comparison and Logical operators
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
19 Basic PHP Tutorial 4: Variables and Comments
Basic PHP Tutorial 4: Variables and Comments
sentdex
20 Basic PHP Tutorial 11: Arrays part 1, basic array
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
21 Basic PHP Tutorial 6: If else and else if conditionals cont'd
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
22 Basic PHP Tutorial 1: Intro to PHP
Basic PHP Tutorial 1: Intro to PHP
sentdex
23 Basic PHP Tutorial 3: HTML with PHP
Basic PHP Tutorial 3: HTML with PHP
sentdex
24 Basic PHP Tutorial 9: While Loop
Basic PHP Tutorial 9: While Loop
sentdex
25 Basic PHP Tutorial 10: Switch Statement
Basic PHP Tutorial 10: Switch Statement
sentdex
26 Basic PHP Tutorial 2: Print and Echo
Basic PHP Tutorial 2: Print and Echo
sentdex
27 Basic PHP Tutorial 5: If else and else if conditional statements
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
28 Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
29 Basic PHP Tutorial 17: User Input Form Example / String Manipulation
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
30 Basic PHP Tutorial 18: HTML Entities and forms cont'd
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
31 Basic PHP Tutorial 19: Finding words in strings
Basic PHP Tutorial 19: Finding words in strings
sentdex
32 Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
33 Basic PHP Programming Tutorial 22: Hashing part 2: salting
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
34 Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
35 Basic PHP Programming Tutorial 21: MD5 Hashing For Security
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
36 Basic PHP Programming Tutorial 24: String similarity
Basic PHP Programming Tutorial 24: String similarity
sentdex
37 Basic PHP Programming Tutorial 25: Time and Time stamps
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
38 Basic PHP Programming Tutorial 26: Die and Exit
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
39 Basic PHP Programming Tutorial 27: MySQL Databases Part 1
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
40 Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
41 Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
42 Basic PHP Programming Tutorial 30: MySQL database in Use
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
43 Django Tutorial Web Development with Python Part 1: Installing Django
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
44 Python Tutorial: File Deletion and Folder Deletion / directory deletion
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
45 Python Tutorial: How to Rename Files and Move Files with Python
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
46 3D Graphs in Matplotlib for Python: Basic 3D Line
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
47 3D Plotting in Matplotlib for Python: 3D Scatter Plot
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
48 3D Charts in Matplotlib for Python: Multiple datasets scatter plot
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
49 Sikuli Tutorial 1: Visually programming in python!
Sikuli Tutorial 1: Visually programming in python!
sentdex
50 Sikuli Tutorial 2: Program visually in python!
Sikuli Tutorial 2: Program visually in python!
sentdex
51 Sikuli Tutorial 3: Program visually in python!
Sikuli Tutorial 3: Program visually in python!
sentdex
52 3D Bar Charts in Python and Matplotlib
3D Bar Charts in Python and Matplotlib
sentdex
53 3D Plane wire frame Graph Chart in Python
3D Plane wire frame Graph Chart in Python
sentdex
54 Raspberry Pi Part 1 Introduction
Raspberry Pi Part 1 Introduction
sentdex
55 Raspberry Pi Part 8: First Download and Update! (Firmware)
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
56 Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
57 Raspberry Pi Part 11: Remote Desktop
Raspberry Pi Part 11: Remote Desktop
sentdex
58 Twitter Analysis: How to rank a user's influence
Twitter Analysis: How to rank a user's influence
sentdex
59 GPIO Tutorial for Pi Part 2 - Programming the GPIO
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
60 GPIO Tutorial for Raspberry Pi Part 1 - Setting up
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex

This video teaches how to add indicators to a GUI using Tkinter, including RSI and MACD calculations, and how to create pop-up messages for user input and validation. It covers GUI development in Python 3.4 and chart customization. By following this tutorial, viewers can learn how to design and implement GUI systems with indicators and user input validation.

Key Takeaways
  1. Add functions to menu items for adding top, middle, and bottom indicators
  2. Create pop-up messages for user input and validation
  3. Use conditional statements for data type checking
  4. Add relative strength index (RSI) calculation with user input for period selection
  5. Insert default value 14 into entry widget
  6. Get value from entry widget using get operation
  7. Append RSI and periods to list
  8. Set top indicator to RSI, 14
  9. Update dat counter to 9000
  10. Copy a function
💡 The video demonstrates how to use Tkinter to create a GUI with indicators and user input validation, and how to customize charts with RSI and MACD calculations.

Related AI Lessons

Up next
How to Open HPL Files (HP-GL Plotter)
File Extension Geeks
Watch →