Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hi guys. I am finance professional who uses python in backend. Now I need to display my analysis in Tkinetr and I faced with the following problem.
In backend I display my pd.Dataframe and apply style.applymap() to change color for specific values ( neg num to red, pos to green). However when I try to display in tkinter the data frame colours do not change. Below is my code. Could you please have a look and say what is wrong and what I am missing?

Your time and help is very much appreciated.

from tkinter import *
from tkinter import ttk

from pandas_datareader._utils import RemoteDataError

import numpy as np
import pandas as pd

from scipy.stats import norm
import requests

from pandas_datareader import data as wb

class Scr():

    def __init__(self, window1):
        = ttk.Style()
        window1.configure(background = 'white')
        tickers = ['MMM']
        mydata = pd.DataFrame()

        for t in tickers : mydata[t] = wb.DataReader(t, data_source ='yahoo', start = '2014-1-1')['Adj Close']
        def color_negative_red(val):
            if val >175.00:
                color = 'green'
            elif val>174.00:
                color = 'orange'
                color = 'red'

            return 'color: %s' % color
        self.frame_content = ttk.Frame(window1)
        ttk.Label( self.frame_content, text = b, foreground='',font = ('Arial', 10,'bold')).grid(row = 0, column = 0, padx = 5, sticky = 'sw')

def main():

    root = Tk()
    scr = Scr(root)

if __name__ == "__main__": main()

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Is there a way to plot pandas dataframes using Plotly, with Tkinter? jbitsch 0 871 May-04-2020, 10:21 PM
Last Post: jbitsch
  TKinter GUI / Pandas Data frame Loop NSearch 0 4,261 Jun-26-2019, 12:37 AM
Last Post: NSearch

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020