hey i'm currently working on a simple rpg in python.
First i was gonna make it text-based but now i've read the wxpython tutorial and i want to try an create a GUI for it. My sister is gonna make some artwork for me (i'm not good at that kind of things). So now i was wondering how i could add a image to a window and also be able to put other things in the window. I know you can use a static bitmap but i don't always know exactly were to place it so that it doesn't show over some other stuff and if i try creating another panel to show it on the whole thing dissapears. this is de code i currently have and i would like to add an image on top of the window.

import wx

class GevechtFrame(wx.Frame):
  def __init__(self):
    wx.Frame.__init__(self, None, title = "mijn rpg 1.0", pos = (200,75),
                      size = (WINDOW_WIDTH,WINDOW_HEIGHT))
    
    self.background = wx.Panel(self)
    #the text arena
    self.textArea = wx.TextCtrl(self.background, style = wx.TE_READONLY | wx.TE_MULTILINE)
    self.textArea.SetValue(""" just a lot of text displaying details about the monster and the hero so i needs some space""")
    #some buttons to attack or use an item or change weapon
    self.aanvalButton = wx.Button(self.background, label = "val aan")
    self.veranderButton = wx.Button(self.background, label = "verander van wapen")
    self.voorwerpButton = wx.Button(self.background, label = "gebruik een voorwerp")
    self.specialeButton = wx.Button(self.background, label = "doe een speciale aanval")
    self.vluchtButton = wx.Button(self.background, label = "vlucht")
    self.vluchtButton.Bind(wx.EVT_BUTTON, self.vlucht_event)
    #putting everything into boxes = creating the layout
    self.HorizontalBox1 = wx.BoxSizer()
    self.HorizontalBox1.Add(self.textArea, proportion = 1, flag = wx.EXPAND, border = 0)
    
    self.HorizontalBox2 = wx.BoxSizer()
    self.HorizontalBox2.Add(self.aanvalButton, proportion = 1, flag = wx.EXPAND, border = 0)
    self.HorizontalBox2.Add(self.veranderButton, proportion = 1, flag = wx.EXPAND, border = 0)
    
    self.HorizontalBox3 = wx.BoxSizer()
    self.HorizontalBox3.Add(self.voorwerpButton, proportion = 1, flag = wx.EXPAND, border = 0)
    self.HorizontalBox3.Add(self.specialeButton, proportion = 1, flag = wx.EXPAND, border = 0)
    
    self.HorizontalBox4 = wx.BoxSizer()
    self.HorizontalBox4.Add(self.vluchtButton, proportion = 1, flag = wx.EXPAND, border = 0)
    
    self.verticalBox = wx.BoxSizer(wx.VERTICAL)
    self.verticalBox.Add(self.HorizontalBox1, proportion = 1, flag = wx.EXPAND, border = 0)
    self.verticalBox.Add(self.HorizontalBox2, proportion = 0, flag = wx.EXPAND, border = 0)
    self.verticalBox.Add(self.HorizontalBox3, proportion = 0, flag = wx.EXPAND, border = 0)
    self.verticalBox.Add(self.HorizontalBox4, proportion = 0, flag = wx.EXPAND, border = 0)
    #showing it
    self.background.SetSizer(self.verticalBox)
    self.Show()
  #just to exit the frame it goes back to the mainframe  
  def vlucht_event(self,event):
    self.Destroy()
    MainFrame()

My suggestion would be to abandon WxPython and use pygame instead. It is much better suited for this type of stuff.

Other than suggestiong you switch to PyGame, I am not sure exactly what you are asking...

What do you mean "add an image on top of the window"? As in on top of the window floating over everything else?

Maybe you'r right about switching to pygame. I'll look into it.

I mean that a want to have a window were i first have an image under that a text area and then some buttons.
window =
image
text
buttons

I guess there is something wrong with my english cause i don't want it as a background just as an image. i'll try to use the static bitmap function but that doesn't work with my sizers so maybe i'm just forced to start reading my book about pygame and try using it for my game.:D
Thanks anyway

I just realized what you want

you want a new frame at the top of your program, above the other content...

I wish I new wxpython better, I don't use it honestly. Maybe someone else can show you how to add a frame with an image in it.

I just realized what you want

you want a new frame at the top of your program, above the other content...

I wish I new wxpython better, I don't use it honestly. Maybe someone else can show you how to add a frame with an image in it.

Don't worry about it you've helped enough already. I think my english isn't the problem i justed wanted to do something you're not supposed to do. I'll put a little example i have here the only difference is that the image is at the bottom

import wx
WINDOW_WIDTH = 600
WINDOW_HEIGHT = 400

class MainFrame(wx.Frame):
  def __init__(self):
    wx.Frame.__init__(self, None, title = "mijn rpg 1.0", pos = (200,75),
                      size = (WINDOW_WIDTH,WINDOW_HEIGHT))
    #sizer en widgets
    #self.imagePanel = wx.Panel(self)
    self.background = wx.Panel(self)

##    self.imagePanel = wx.Panel(self)
    imageFile = "some_image.jpg"
    self.jpg1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
    wx.StaticBitmap(self.background, -1, self.jpg1, (20,100), (self.jpg1.GetWidth(),self.jpg1.GetHeight()))
##
##    self.textArea = wx.TextCtrl(self.background, style = wx.TE_READONLY | wx.TE_MULTILINE)
##    self.textArea.SetValue(kaart2)

    self.bosBtn = wx.Button(self.background, label = "bos")
    self.bosBtn.Bind(wx.EVT_BUTTON, self.gevecht_event)
    self.stadBtn = wx.Button(self.background, label ="stad")
    self.bergenBtn = wx.Button(self.background, label ="bergen")
    self.villaBtn = wx.Button(self.background, label ="villa")
    self.saveBtn = wx.Button(self.background, label ="opslaan en sluiten")
    self.saveBtn.Bind(wx.EVT_BUTTON, self.save_event)

    self.horizontalbox1 = wx.BoxSizer()
    self.horizontalbox2 = wx.BoxSizer()
    self.horizontalbox3 = wx.BoxSizer()

    self.horizontalbox1.Add(self.bosBtn, proportion = 1, border = 0)
    self.horizontalbox1.Add(self.stadBtn, proportion = 1, border = 0)

    self.horizontalbox2.Add(self.bergenBtn, proportion = 1, border = 0)
    self.horizontalbox2.Add(self.villaBtn, proportion = 1, border = 0)

    self.horizontalbox3.Add(self.saveBtn, proportion = 1, border = 0)

    self.verticalBox = wx.BoxSizer(wx.VERTICAL)
##    self.verticalBox.Add(self.textArea, proportion = 1, flag = wx.EXPAND, border = 0)
    self.verticalBox.Add(self.horizontalbox1, proportion = 0, flag = wx.EXPAND, border = 0)
    self.verticalBox.Add(self.horizontalbox2, proportion = 0, flag = wx.EXPAND, border = 0)
    self.verticalBox.Add(self.horizontalbox3, proportion = 0, flag = wx.EXPAND, border = 0)

  
    self.background.SetSizer(self.verticalBox)
    self.Show()
  def save_event(self, event):
    exit()

this comes straight out the starting wxpython post i just combined it a little bit

This question has already been answered. Start a new discussion instead.