Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9129131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:40:34+00:00 2026-06-17T07:40:34+00:00

I’m a beginner in python. All i want to do is create a simple

  • 0

I’m a beginner in python. All i want to do is create a simple GUI that implements basic Digital Image processing Algorithms.
I want to adjust brightness of an image with tkinter slider. but this is not working and i am clueless as i’m just beginner. I am expecting the scale widget callback to do some brightness adjustment work but due too some reason the call back is not being invoked.

Here is my code:

import Tkinter as tk
import Image
import ImageTk
import numpy as np
import tkFileDialog

class DIP(tk.Frame):
    def __init__(self, parent):
        tk.Frame.__init__(self, parent) 
        self.parent = parent        
        self.initUI()

    def initUI(self):
        self.parent.title("DIP Algorithms- Simple Photo Editor")
        self.pack(fill = tk.BOTH, expand = 1)

        menubar = tk.Menu(self.parent)
        self.parent.config(menu = menubar)

        self.label1 = tk.Label(self, border = 25)
        self.label2 = tk.Label(self, border = 25)
        self.label1.grid(row = 1, column = 1)
        self.label2.grid(row = 1, column = 2)

        # File Menu
        fileMenu = tk.Menu(menubar)
        menubar.add_cascade(label = "File", menu = fileMenu)

        # Menu Item for Open Image
        fileMenu.add_command(label = "Open", command = self.onOpen)        

        # Basic menu
        basicMenu = tk.Menu(menubar)        
        menubar.add_cascade(label = "Basic", menu = basicMenu)

        # Menu Item for image negative
        basicMenu.add_command(label = "Negative", command = self.onNeg)

        #menu for brightness
        basicMenu.add_command(label = "Brightness", command = self.onBrghtness)

    def onBrghtness(self):
        #Image Brightness Adjustment Menu callback
        brgTk=tk.Tk()
        self.brgSc = tk.Scale( brgTk, from_=-50, to=50, orient=tk.HORIZONTAL, command=self.adjBright, length=200 ,width=10, sliderlength=15)
        self.brgSc.pack(anchor=tk.CENTER)

    def adjBright(self):
        print self.brgSc #***here how can i get slider value, this callback is not being invoked***???

    def onNeg(self):
        #Image Negative Menu callback
        self.I2 = 255-self.I;
        self.im = Image.fromarray(np.uint8(self.I2))
        photo2 = ImageTk.PhotoImage(self.im)
        self.label2.configure(image=photo2)
        self.label2.image = photo2 # keep a reference!

    def setImage(self):
        self.img = Image.open(self.fn)
        self.I = np.asarray(self.img)
        l, h = self.img.size
        text = str(2*l+100)+"x"+str(h+50)+"+0+0"
        self.parent.geometry(text)
        photo = ImageTk.PhotoImage(self.img)
        self.label1.configure(image = photo)
        self.label1.image = photo # keep a reference!

    def onOpen(self):
        #Open Callback
        ftypes = [('Image Files', '*.tif *.jpg *.png')]
        dlg = tkFileDialog.Open(self, filetypes = ftypes)
        filename = dlg.show()
        self.fn = filename
        #print self.fn #prints filename with path here
        self.setImage()

    #def onError(self):
        #box.showerror("Error", "Could not open file")    


def main():
    root = tk.Tk()
    DIP(root)
    root.geometry("320x240")
    root.mainloop()  

if __name__ == '__main__':
    main()

At the code where i mentioned the problem, the callback is failed because it says something like:

Traceback (most recent call last):
  File "C:\Python27\lib\lib-tk\Tkinter.py", line 1410, in __call__
    return self.func(*args) 
TypeError: adjBright() takes exactly 1 argument (2 given)

Please do help, i know it may be stupid type of question to ask, but i’m just beginner and i hope i’ll have deep understanding of PYTHON with time…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:40:35+00:00Added an answer on June 17, 2026 at 7:40 am

    Traceback (most recent call last): File
    “C:\Python27\lib\lib-tk\Tkinter.py”, line 1410, in call return
    self.func(*args) TypeError: adjBright() takes exactly 1 argument (2
    given)

    You are getting this error because the scale callback is always passed the new value of the scale. Since you define adjBright to only have self as an argument, Tkinter throws an error. Unfortunately, this seems to be a somewhat under-documented feature of Tkinter.

    Add another argument to adjBright, then you don’t have to worry about fetching the new value:

    def adjBright(self, new_value):
        print "the slider value is", new_value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.