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

  • SEARCH
  • Home
  • 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 7886787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:24:33+00:00 2026-06-03T05:24:33+00:00

My GUI with following code does not have threads.The image display hogs up lots

  • 0

My GUI with following code does not have threads.The image display hogs up lots of memory and GUI is blocked ,and I can only call one function at a time.Please suggest simple hacks to make the GUI faster.Anyways The Image processing tasks like Clustering takes 5-6 mins.

import wx
import sys
import os
import matplotlib
import OpenGL
import PIL
import time
from spectral.graphics.hypercube import hypercube
from spectral import *
init_graphics()

class RedirectText(object):
 def __init__(self,awxTextCtrl):
    self.out=awxTextCtrl

def write(self,string):
    self.out.WriteText(string)            


 class Frame(wx.Frame):
def __init__(self, title,*args,**kwargs):
    wx.Frame.__init__(self, None, title=title, size=       (1000,85),style=wx.MINIMIZE_BOX|wx.CLOSE_BOX|wx.RESIZE_BORDER|wx.SYSTEM_MENU|wx.CAPTION|wx.CLIP_CHILDREN)
    self.Bind(wx.EVT_CLOSE, self.OnClose)
    panel=wx.Panel(self,-1)
    self.button=wx.Button(panel,label="Open",pos=(0,0),size=(50,30))
    self.button1=wx.Button(panel,label="Save",pos=(51,0),size=(50,30))
    self.button2=wx.Button(panel,label="ROI",pos=(102,0),size=(50,30))
    self.button3=wx.Button(panel,label="Tone",pos=(153,0),size=(50,30))
    self.slider=wx.Slider(panel,pos=(204,0))
    self.button4=wx.Button(panel,label="Header",pos=(305,0),size=(50,30))
    self.button5=wx.Button(panel,label="Cluster",pos=(356,0),size=(50,30))
    self.button6=wx.Button(panel,label="Cube",pos=(407,0),size=(50,30))
    self.button7=wx.Button(panel,label="Gaussian",pos=(458,0),size=(50,30))
    self.Bind(wx.EVT_BUTTON, self.OnCubeClick,self.button5)
    self.Bind(wx.EVT_BUTTON, self.OnHeadClick,self.button4)
    self.Bind(wx.EVT_BUTTON, self.OnSaveClick,self.button1)
    self.Bind(wx.EVT_BUTTON, self.OnButtonClick,self.button)
    self.Bind(wx.EVT_BUTTON, self.OnCClick,self.button6)
    self.Bind(wx.EVT_BUTTON, self.OnGClick,self.button7)
    #self.std=wx.TextCtrl(panel,pos=(0,31), size=(500,-1))
    self.loc=wx.TextCtrl(panel,pos=(700,0), size=(300,-1))
    self.status = wx.TextCtrl(panel,-1,'Choose file',pos=(800,22),size=(200,-1))
    #redir=RedirectText(self.std)
    #sys.stdout=redir


def OnButtonClick(self,event):
    wild="HSi Files|*.lan*|All Files|*.*"
    dlg=wx.FileDialog(self,message="Choose a File",wildcard=wild,style=wx.FD_OPEN)
    if dlg.ShowModal() == wx.ID_OK:
        time.sleep(0.5)
        self.loc.SetValue(dlg.GetPath())
        dlg.Destroy()
        self.Onview()

def Onview(self):
    filepath=self.loc.GetValue()
    img=image(filepath)
    time.sleep(1)
    view(img)
    time.sleep(1)
    self.status.SetValue('View Ready')



def OnHeadClick(self,event):

    filepath=self.loc.GetValue()
    img=image(filepath)
    self.status.SetValue(img.shape)

def OnCubeClick(self,event):
    time.sleep(0.2)
    self.status.SetValue('Clustering')
    filepath=self.loc.GetValue()
    img= image(filepath).load()
    (m, c) = cluster(img, 20)
    view_indexed(m)
    self.status.SetValue('Clustering View Ready')

def OnCClick(self,event):
    self.status.SetValue('Cube view')
    time.sleep(5)
    filepath=self.loc.GetValue()
    img= image(filepath).load()
    hypercube(img, bands=[29, 19, 9])

def OnGClick(self,event):
    self.status.SetValue('Gaussian procesing')
    time.sleep(30)
    filepath=self.loc.GetValue()
    gt=image(filepath).read_band(0)
    img=image(filepath)
    classes = create_training_classes(img,gt)
    gmlc = GaussianClassifier(classes)
    clMap = gmlc.classify_image(img)
    view_indexed(clMap)
    self.status.SetLabel('Gaussian Ready')


def OnSaveClick(self,event):
    self.status.SetValue('Save File')
    wild="HSi Files|*.lan*|All Files|*.*"
    dlg=wx.FileDialog(self,message="Save AS",wildcard=wild,style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT)
    if dlg.ShowModal() == wx.ID_OK:
        path=dlg.GetPath()
        self.Save(path)
        self.file=path
        dlg.Destroy()


def OnClose(self, event):
    dlg = wx.MessageDialog(self, 
        "Do you really want to close BBvw ?",
        "Confirm Exit", wx.OK|wx.CANCEL|wx.ICON_QUESTION)
    result = dlg.ShowModal()
    dlg.Destroy()
    if result == wx.ID_OK:
        self.Destroy()




  app = wx.App(redirect=False)
  top = Frame("BBvw")
  top.Show()
  app.MainLoop()
  • 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-03T05:24:34+00:00Added an answer on June 3, 2026 at 5:24 am

    Long running processes should always go into separate threads. Otherwise they will block the GUI’s mainloop. If displaying the image is taking up lots of memory, then I’m guessing you’re displaying high res photos at full resolution. Try creating a set of lower resolution photos for displaying instead (like thumbnails or something). Unless you need the full resolution displayed, don’t do it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I can not understand a single moment. The following code in a simple
I've been writing Java swing GUI code for several years but the following syntax
I am using GridLayout in my SWT GUI app. I have the following GridData
I have a problem with understanding the following code: import java.awt.Dimension; import java.awt.GridLayout; import
Say I have the following code: import java.lang.InterruptedException; import javax.swing.SwingWorker; public class Test {
I have some Matlab code and a GUI for it and I want to
I have got a window that should display the following: JLablel Have you used
I have the following java code fragment while (condition1){ switch (someinteger){ case 1: if(condition2)
I'm creating a Java application in NetBeans, and I have the following code that
I have a workspace with the following 3 projects: Library Tests GUI The tests

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.