Retina images in wxPython

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Retina images in wxPython

dontblink
Hi everyone,

I understand wxPython has support for retina text, but no matter what I do I cannot get retina support working for images.

Does anyone have an idea on how to get it to work if possible? Do I need to patch wxWidgets and rebuild wxPython?  Whats the least version that supports retina?

If anyone has a sample demo script that works I'd appreciate an example.

Thanks,

-R

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Retina images in wxPython

Igor Korot
Hi,

On Mon, May 22, 2017 at 3:13 PM, Rishi Sharma <[hidden email]> wrote:

> Hi everyone,
>
> I understand wxPython has support for retina text, but no matter what I do I
> cannot get retina support working for images.
>
> Does anyone have an idea on how to get it to work if possible? Do I need to
> patch wxWidgets and rebuild wxPython?  Whats the least version that supports
> retina?
>
> If anyone has a sample demo script that works I'd appreciate an example.

What is your {wx}python versions?
What OSX version?
Are you sure you have a Retina display?

Thank you.

>
> Thanks,
>
> -R
>
> --
> You received this message because you are subscribed to the Google Groups
> "wxPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Retina images in wxPython

dontblink
Hi!

I have a Macbook Pro Retina Touchbar.  I made sure the screen is set to Default.

This is what I have found so far.  I'm using wxPython 3.0.1.0 (although I've tried to use the 4.0 version as well).  Below is a sample script I wrote (requires AppKit PyObjC to check for backingScaleFactor).  I made sure to look at the backingScaleFactor and found it correctly it returns 2.  I'm looking at the bitmap code block and do see support:

        if  ( type == wxBITMAP_TYPE_PNG )
        {
            if ( wxOSXGetMainScreenContentScaleFactor() > 1.9 )
            {
                wxFileName fn(filename);
                fn.MakeAbsolute();
                fn.SetName(fn.GetName()+"@2x");
                
                if ( fn.Exists() )
                {
                    fname = fn.GetFullPath();
                    scale = 2.0;
                }
            }
        }

I just have no idea why its not working.  Here is the sample:

import AppKit as AK
import wx

class MyFrame(wx.Frame):
  def __init__(self, parent):
    wx.Frame.__init__(self, parent, -1, "Retina Demo")
    print AK.NSScreen.screens()[0].backingScaleFactor()
    path = "img.png"
    bmp = wx.EmptyBitmap( 1, 1 )
    bmp.LoadFile(path, wx.BITMAP_TYPE_PNG)
    bmp = wx.StaticBitmap(self, -1, bmp)
    sizer = wx.BoxSizer(wx.VERTICAL)
    sizer.Add(bmp, 1, wx.ALL|wx.EXPAND, 5)
    self.SetSizer(sizer)
    sizer.Fit(self)
    self.Layout()

app = wx.App()
frame = MyFrame(None)
app.SetTopWindow(frame)
frame.Show()
app.MainLoop()

On Mon, May 22, 2017 at 12:20 PM, Igor Korot <[hidden email]> wrote:
Hi,

On Mon, May 22, 2017 at 3:13 PM, Rishi Sharma <[hidden email]> wrote:
> Hi everyone,
>
> I understand wxPython has support for retina text, but no matter what I do I
> cannot get retina support working for images.
>
> Does anyone have an idea on how to get it to work if possible? Do I need to
> patch wxWidgets and rebuild wxPython?  Whats the least version that supports
> retina?
>
> If anyone has a sample demo script that works I'd appreciate an example.

What is your {wx}python versions?
What OSX version?
Are you sure you have a Retina display?

Thank you.

>
> Thanks,
>
> -R
>
> --
> You received this message because you are subscribed to the Google Groups
> "wxPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Retina images in wxPython

dontblink
In order to test it uses the correct image, I have img.png and [hidden email] (both are actually different images so I can tell which one is loaded).

On Mon, May 22, 2017 at 1:02 PM, Rishi Sharma <[hidden email]> wrote:
Hi!

I have a Macbook Pro Retina Touchbar.  I made sure the screen is set to Default.

This is what I have found so far.  I'm using wxPython 3.0.1.0 (although I've tried to use the 4.0 version as well).  Below is a sample script I wrote (requires AppKit PyObjC to check for backingScaleFactor).  I made sure to look at the backingScaleFactor and found it correctly it returns 2.  I'm looking at the bitmap code block and do see support:

        if  ( type == wxBITMAP_TYPE_PNG )
        {
            if ( wxOSXGetMainScreenContentScaleFactor() > 1.9 )
            {
                wxFileName fn(filename);
                fn.MakeAbsolute();
                fn.SetName(fn.GetName()+"@2x");
                
                if ( fn.Exists() )
                {
                    fname = fn.GetFullPath();
                    scale = 2.0;
                }
            }
        }

I just have no idea why its not working.  Here is the sample:

import AppKit as AK
import wx

class MyFrame(wx.Frame):
  def __init__(self, parent):
    wx.Frame.__init__(self, parent, -1, "Retina Demo")
    print AK.NSScreen.screens()[0].backingScaleFactor()
    path = "img.png"
    bmp = wx.EmptyBitmap( 1, 1 )
    bmp.LoadFile(path, wx.BITMAP_TYPE_PNG)
    bmp = wx.StaticBitmap(self, -1, bmp)
    sizer = wx.BoxSizer(wx.VERTICAL)
    sizer.Add(bmp, 1, wx.ALL|wx.EXPAND, 5)
    self.SetSizer(sizer)
    sizer.Fit(self)
    self.Layout()

app = wx.App()
frame = MyFrame(None)
app.SetTopWindow(frame)
frame.Show()
app.MainLoop()

On Mon, May 22, 2017 at 12:20 PM, Igor Korot <[hidden email]> wrote:
Hi,

On Mon, May 22, 2017 at 3:13 PM, Rishi Sharma <[hidden email]> wrote:
> Hi everyone,
>
> I understand wxPython has support for retina text, but no matter what I do I
> cannot get retina support working for images.
>
> Does anyone have an idea on how to get it to work if possible? Do I need to
> patch wxWidgets and rebuild wxPython?  Whats the least version that supports
> retina?
>
> If anyone has a sample demo script that works I'd appreciate an example.

What is your {wx}python versions?
What OSX version?
Are you sure you have a Retina display?

Thank you.

>
> Thanks,
>
> -R
>
> --
> You received this message because you are subscribed to the Google Groups
> "wxPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Retina images in wxPython

Igor Korot
Hi,

On Mon, May 22, 2017 at 4:03 PM, Rishi Sharma <[hidden email]> wrote:
> In order to test it uses the correct image, I have img.png and [hidden email]
> (both are actually different images so I can tell which one is loaded).

Are they both accessible?
Just for the test - can you try to load both of them and check that
the bitmap IsOk()
returns true?

Thank you.

>
> On Mon, May 22, 2017 at 1:02 PM, Rishi Sharma <[hidden email]> wrote:
>>
>> Hi!
>>
>> I have a Macbook Pro Retina Touchbar.  I made sure the screen is set to
>> Default.
>>
>> This is what I have found so far.  I'm using wxPython 3.0.1.0 (although
>> I've tried to use the 4.0 version as well).  Below is a sample script I
>> wrote (requires AppKit PyObjC to check for backingScaleFactor).  I made sure
>> to look at the backingScaleFactor and found it correctly it returns 2.  I'm
>> looking at the bitmap code block and do see support:
>>
>>         if  ( type == wxBITMAP_TYPE_PNG )
>>         {
>>             if ( wxOSXGetMainScreenContentScaleFactor() > 1.9 )
>>             {
>>                 wxFileName fn(filename);
>>                 fn.MakeAbsolute();
>>                 fn.SetName(fn.GetName()+"@2x");
>>
>>                 if ( fn.Exists() )
>>                 {
>>                     fname = fn.GetFullPath();
>>                     scale = 2.0;
>>                 }
>>             }
>>         }
>>
>> I just have no idea why its not working.  Here is the sample:
>>
>> import AppKit as AK
>> import wx
>>
>> class MyFrame(wx.Frame):
>>   def __init__(self, parent):
>>     wx.Frame.__init__(self, parent, -1, "Retina Demo")
>>     print AK.NSScreen.screens()[0].backingScaleFactor()
>>     path = "img.png"
>>     bmp = wx.EmptyBitmap( 1, 1 )
>>     bmp.LoadFile(path, wx.BITMAP_TYPE_PNG)
>>     bmp = wx.StaticBitmap(self, -1, bmp)
>>     sizer = wx.BoxSizer(wx.VERTICAL)
>>     sizer.Add(bmp, 1, wx.ALL|wx.EXPAND, 5)
>>     self.SetSizer(sizer)
>>     sizer.Fit(self)
>>     self.Layout()
>>
>> app = wx.App()
>> frame = MyFrame(None)
>> app.SetTopWindow(frame)
>> frame.Show()
>> app.MainLoop()
>>
>> On Mon, May 22, 2017 at 12:20 PM, Igor Korot <[hidden email]> wrote:
>>>
>>> Hi,
>>>
>>> On Mon, May 22, 2017 at 3:13 PM, Rishi Sharma <[hidden email]>
>>> wrote:
>>> > Hi everyone,
>>> >
>>> > I understand wxPython has support for retina text, but no matter what I
>>> > do I
>>> > cannot get retina support working for images.
>>> >
>>> > Does anyone have an idea on how to get it to work if possible? Do I
>>> > need to
>>> > patch wxWidgets and rebuild wxPython?  Whats the least version that
>>> > supports
>>> > retina?
>>> >
>>> > If anyone has a sample demo script that works I'd appreciate an
>>> > example.
>>>
>>> What is your {wx}python versions?
>>> What OSX version?
>>> Are you sure you have a Retina display?
>>>
>>> Thank you.
>>>
>>> >
>>> > Thanks,
>>> >
>>> > -R
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> > Groups
>>> > "wxPython-users" group.
>>> > To unsubscribe from this group and stop receiving emails from it, send
>>> > an
>>> > email to [hidden email].
>>> > For more options, visit https://groups.google.com/d/optout.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "wxPython-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to [hidden email].
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "wxPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Retina images in wxPython

dontblink


On Mon, May 22, 2017 at 1:11 PM, Igor Korot <[hidden email]> wrote:
Hi,

On Mon, May 22, 2017 at 4:03 PM, Rishi Sharma <[hidden email]> wrote:
> In order to test it uses the correct image, I have img.png and [hidden email]
> (both are actually different images so I can tell which one is loaded).

Are they both accessible?
Just for the test - can you try to load both of them and check that
the bitmap IsOk()
returns true?

Done, both return True.  Are you able to get the 2x image loaded with the script below (using substitute images)?
 

Thank you.

>
> On Mon, May 22, 2017 at 1:02 PM, Rishi Sharma <[hidden email]> wrote:
>>
>> Hi!
>>
>> I have a Macbook Pro Retina Touchbar.  I made sure the screen is set to
>> Default.
>>
>> This is what I have found so far.  I'm using wxPython 3.0.1.0 (although
>> I've tried to use the 4.0 version as well).  Below is a sample script I
>> wrote (requires AppKit PyObjC to check for backingScaleFactor).  I made sure
>> to look at the backingScaleFactor and found it correctly it returns 2.  I'm
>> looking at the bitmap code block and do see support:
>>
>>         if  ( type == wxBITMAP_TYPE_PNG )
>>         {
>>             if ( wxOSXGetMainScreenContentScaleFactor() > 1.9 )
>>             {
>>                 wxFileName fn(filename);
>>                 fn.MakeAbsolute();
>>                 fn.SetName(fn.GetName()+"@2x");
>>
>>                 if ( fn.Exists() )
>>                 {
>>                     fname = fn.GetFullPath();
>>                     scale = 2.0;
>>                 }
>>             }
>>         }
>>
>> I just have no idea why its not working.  Here is the sample:
>>
>> import AppKit as AK
>> import wx
>>
>> class MyFrame(wx.Frame):
>>   def __init__(self, parent):
>>     wx.Frame.__init__(self, parent, -1, "Retina Demo")
>>     print AK.NSScreen.screens()[0].backingScaleFactor()
>>     path = "img.png"
>>     bmp = wx.EmptyBitmap( 1, 1 )
>>     bmp.LoadFile(path, wx.BITMAP_TYPE_PNG)
>>     bmp = wx.StaticBitmap(self, -1, bmp)
>>     sizer = wx.BoxSizer(wx.VERTICAL)
>>     sizer.Add(bmp, 1, wx.ALL|wx.EXPAND, 5)
>>     self.SetSizer(sizer)
>>     sizer.Fit(self)
>>     self.Layout()
>>
>> app = wx.App()
>> frame = MyFrame(None)
>> app.SetTopWindow(frame)
>> frame.Show()
>> app.MainLoop()
>>
>> On Mon, May 22, 2017 at 12:20 PM, Igor Korot <[hidden email]> wrote:
>>>
>>> Hi,
>>>
>>> On Mon, May 22, 2017 at 3:13 PM, Rishi Sharma <[hidden email]>
>>> wrote:
>>> > Hi everyone,
>>> >
>>> > I understand wxPython has support for retina text, but no matter what I
>>> > do I
>>> > cannot get retina support working for images.
>>> >
>>> > Does anyone have an idea on how to get it to work if possible? Do I
>>> > need to
>>> > patch wxWidgets and rebuild wxPython?  Whats the least version that
>>> > supports
>>> > retina?
>>> >
>>> > If anyone has a sample demo script that works I'd appreciate an
>>> > example.
>>>
>>> What is your {wx}python versions?
>>> What OSX version?
>>> Are you sure you have a Retina display?
>>>
>>> Thank you.
>>>
>>> >
>>> > Thanks,
>>> >
>>> > -R
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> > Groups
>>> > "wxPython-users" group.
>>> > To unsubscribe from this group and stop receiving emails from it, send
>>> > an
>>> > email to [hidden email].
>>> > For more options, visit https://groups.google.com/d/optout.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "wxPython-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to [hidden email].
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "wxPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Retina images in wxPython

Igor Korot
Hi,

On Mon, May 22, 2017 at 4:44 PM, Rishi Sharma <[hidden email]> wrote:

>
>
> On Mon, May 22, 2017 at 1:11 PM, Igor Korot <[hidden email]> wrote:
>>
>> Hi,
>>
>> On Mon, May 22, 2017 at 4:03 PM, Rishi Sharma <[hidden email]>
>> wrote:
>> > In order to test it uses the correct image, I have img.png and
>> > [hidden email]
>> > (both are actually different images so I can tell which one is loaded).
>>
>> Are they both accessible?
>> Just for the test - can you try to load both of them and check that
>> the bitmap IsOk()
>> returns true?
>
>
> Done, both return True.  Are you able to get the 2x image loaded with the
> script below (using substitute images)?

I don't have Mac with Retina.
Now you can successfully render the "@2" bitmap into the screen, right?
Maybe wxPython does not compile this code?

Thank you.

>
>>
>>
>> Thank you.
>>
>> >
>> > On Mon, May 22, 2017 at 1:02 PM, Rishi Sharma <[hidden email]>
>> > wrote:
>> >>
>> >> Hi!
>> >>
>> >> I have a Macbook Pro Retina Touchbar.  I made sure the screen is set to
>> >> Default.
>> >>
>> >> This is what I have found so far.  I'm using wxPython 3.0.1.0 (although
>> >> I've tried to use the 4.0 version as well).  Below is a sample script I
>> >> wrote (requires AppKit PyObjC to check for backingScaleFactor).  I made
>> >> sure
>> >> to look at the backingScaleFactor and found it correctly it returns 2.
>> >> I'm
>> >> looking at the bitmap code block and do see support:
>> >>
>> >>         if  ( type == wxBITMAP_TYPE_PNG )
>> >>         {
>> >>             if ( wxOSXGetMainScreenContentScaleFactor() > 1.9 )
>> >>             {
>> >>                 wxFileName fn(filename);
>> >>                 fn.MakeAbsolute();
>> >>                 fn.SetName(fn.GetName()+"@2x");
>> >>
>> >>                 if ( fn.Exists() )
>> >>                 {
>> >>                     fname = fn.GetFullPath();
>> >>                     scale = 2.0;
>> >>                 }
>> >>             }
>> >>         }
>> >>
>> >> I just have no idea why its not working.  Here is the sample:
>> >>
>> >> import AppKit as AK
>> >> import wx
>> >>
>> >> class MyFrame(wx.Frame):
>> >>   def __init__(self, parent):
>> >>     wx.Frame.__init__(self, parent, -1, "Retina Demo")
>> >>     print AK.NSScreen.screens()[0].backingScaleFactor()
>> >>     path = "img.png"
>> >>     bmp = wx.EmptyBitmap( 1, 1 )
>> >>     bmp.LoadFile(path, wx.BITMAP_TYPE_PNG)
>> >>     bmp = wx.StaticBitmap(self, -1, bmp)
>> >>     sizer = wx.BoxSizer(wx.VERTICAL)
>> >>     sizer.Add(bmp, 1, wx.ALL|wx.EXPAND, 5)
>> >>     self.SetSizer(sizer)
>> >>     sizer.Fit(self)
>> >>     self.Layout()
>> >>
>> >> app = wx.App()
>> >> frame = MyFrame(None)
>> >> app.SetTopWindow(frame)
>> >> frame.Show()
>> >> app.MainLoop()
>> >>
>> >> On Mon, May 22, 2017 at 12:20 PM, Igor Korot <[hidden email]>
>> >> wrote:
>> >>>
>> >>> Hi,
>> >>>
>> >>> On Mon, May 22, 2017 at 3:13 PM, Rishi Sharma <[hidden email]>
>> >>> wrote:
>> >>> > Hi everyone,
>> >>> >
>> >>> > I understand wxPython has support for retina text, but no matter
>> >>> > what I
>> >>> > do I
>> >>> > cannot get retina support working for images.
>> >>> >
>> >>> > Does anyone have an idea on how to get it to work if possible? Do I
>> >>> > need to
>> >>> > patch wxWidgets and rebuild wxPython?  Whats the least version that
>> >>> > supports
>> >>> > retina?
>> >>> >
>> >>> > If anyone has a sample demo script that works I'd appreciate an
>> >>> > example.
>> >>>
>> >>> What is your {wx}python versions?
>> >>> What OSX version?
>> >>> Are you sure you have a Retina display?
>> >>>
>> >>> Thank you.
>> >>>
>> >>> >
>> >>> > Thanks,
>> >>> >
>> >>> > -R
>> >>> >
>> >>> > --
>> >>> > You received this message because you are subscribed to the Google
>> >>> > Groups
>> >>> > "wxPython-users" group.
>> >>> > To unsubscribe from this group and stop receiving emails from it,
>> >>> > send
>> >>> > an
>> >>> > email to [hidden email].
>> >>> > For more options, visit https://groups.google.com/d/optout.
>> >>>
>> >>> --
>> >>> You received this message because you are subscribed to the Google
>> >>> Groups
>> >>> "wxPython-users" group.
>> >>> To unsubscribe from this group and stop receiving emails from it, send
>> >>> an
>> >>> email to [hidden email].
>> >>> For more options, visit https://groups.google.com/d/optout.
>> >>
>> >>
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "wxPython-users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to [hidden email].
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "wxPython-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [hidden email].
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "wxPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Retina images in wxPython

dontblink


On Mon, May 22, 2017 at 1:56 PM, Igor Korot <[hidden email]> wrote:
Hi,

On Mon, May 22, 2017 at 4:44 PM, Rishi Sharma <[hidden email]> wrote:
>
>
> On Mon, May 22, 2017 at 1:11 PM, Igor Korot <[hidden email]> wrote:
>>
>> Hi,
>>
>> On Mon, May 22, 2017 at 4:03 PM, Rishi Sharma <[hidden email]>
>> wrote:
>> > In order to test it uses the correct image, I have img.png and
>> > [hidden email]
>> > (both are actually different images so I can tell which one is loaded).
>>
>> Are they both accessible?
>> Just for the test - can you try to load both of them and check that
>> the bitmap IsOk()
>> returns true?
>
>
> Done, both return True.  Are you able to get the 2x image loaded with the
> script below (using substitute images)?

I don't have Mac with Retina.
Now you can successfully render the "@2" bitmap into the screen, right?
Maybe wxPython does not compile this code?

Yeah, but its rendered scaled up for the 2.0 factor.  I'm not sure how wxPython would not compile the code since it seems to be in the wxwidgets source included with it.  I did originally download the binary though, so perhaps something in the binary had it off.   

I can't find a single success story about retina and wxPython via google so not sure whats up.  
 

Thank you.

>
>>
>>
>> Thank you.
>>
>> >
>> > On Mon, May 22, 2017 at 1:02 PM, Rishi Sharma <[hidden email]>
>> > wrote:
>> >>
>> >> Hi!
>> >>
>> >> I have a Macbook Pro Retina Touchbar.  I made sure the screen is set to
>> >> Default.
>> >>
>> >> This is what I have found so far.  I'm using wxPython 3.0.1.0 (although
>> >> I've tried to use the 4.0 version as well).  Below is a sample script I
>> >> wrote (requires AppKit PyObjC to check for backingScaleFactor).  I made
>> >> sure
>> >> to look at the backingScaleFactor and found it correctly it returns 2.
>> >> I'm
>> >> looking at the bitmap code block and do see support:
>> >>
>> >>         if  ( type == wxBITMAP_TYPE_PNG )
>> >>         {
>> >>             if ( wxOSXGetMainScreenContentScaleFactor() > 1.9 )
>> >>             {
>> >>                 wxFileName fn(filename);
>> >>                 fn.MakeAbsolute();
>> >>                 fn.SetName(fn.GetName()+"@2x");
>> >>
>> >>                 if ( fn.Exists() )
>> >>                 {
>> >>                     fname = fn.GetFullPath();
>> >>                     scale = 2.0;
>> >>                 }
>> >>             }
>> >>         }
>> >>
>> >> I just have no idea why its not working.  Here is the sample:
>> >>
>> >> import AppKit as AK
>> >> import wx
>> >>
>> >> class MyFrame(wx.Frame):
>> >>   def __init__(self, parent):
>> >>     wx.Frame.__init__(self, parent, -1, "Retina Demo")
>> >>     print AK.NSScreen.screens()[0].backingScaleFactor()
>> >>     path = "img.png"
>> >>     bmp = wx.EmptyBitmap( 1, 1 )
>> >>     bmp.LoadFile(path, wx.BITMAP_TYPE_PNG)
>> >>     bmp = wx.StaticBitmap(self, -1, bmp)
>> >>     sizer = wx.BoxSizer(wx.VERTICAL)
>> >>     sizer.Add(bmp, 1, wx.ALL|wx.EXPAND, 5)
>> >>     self.SetSizer(sizer)
>> >>     sizer.Fit(self)
>> >>     self.Layout()
>> >>
>> >> app = wx.App()
>> >> frame = MyFrame(None)
>> >> app.SetTopWindow(frame)
>> >> frame.Show()
>> >> app.MainLoop()
>> >>
>> >> On Mon, May 22, 2017 at 12:20 PM, Igor Korot <[hidden email]>
>> >> wrote:
>> >>>
>> >>> Hi,
>> >>>
>> >>> On Mon, May 22, 2017 at 3:13 PM, Rishi Sharma <[hidden email]>
>> >>> wrote:
>> >>> > Hi everyone,
>> >>> >
>> >>> > I understand wxPython has support for retina text, but no matter
>> >>> > what I
>> >>> > do I
>> >>> > cannot get retina support working for images.
>> >>> >
>> >>> > Does anyone have an idea on how to get it to work if possible? Do I
>> >>> > need to
>> >>> > patch wxWidgets and rebuild wxPython?  Whats the least version that
>> >>> > supports
>> >>> > retina?
>> >>> >
>> >>> > If anyone has a sample demo script that works I'd appreciate an
>> >>> > example.
>> >>>
>> >>> What is your {wx}python versions?
>> >>> What OSX version?
>> >>> Are you sure you have a Retina display?
>> >>>
>> >>> Thank you.
>> >>>
>> >>> >
>> >>> > Thanks,
>> >>> >
>> >>> > -R
>> >>> >
>> >>> > --
>> >>> > You received this message because you are subscribed to the Google
>> >>> > Groups
>> >>> > "wxPython-users" group.
>> >>> > To unsubscribe from this group and stop receiving emails from it,
>> >>> > send
>> >>> > an
>> >>> > email to [hidden email].
>> >>> > For more options, visit https://groups.google.com/d/optout.
>> >>>
>> >>> --
>> >>> You received this message because you are subscribed to the Google
>> >>> Groups
>> >>> "wxPython-users" group.
>> >>> To unsubscribe from this group and stop receiving emails from it, send
>> >>> an
>> >>> email to [hidden email].
>> >>> For more options, visit https://groups.google.com/d/optout.
>> >>
>> >>
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "wxPython-users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to [hidden email].
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "wxPython-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [hidden email].
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "wxPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Retina images in wxPython

Igor Korot
Hi,

On Mon, May 22, 2017 at 5:08 PM, Rishi Sharma <[hidden email]> wrote:

>
>
> On Mon, May 22, 2017 at 1:56 PM, Igor Korot <[hidden email]> wrote:
>>
>> Hi,
>>
>> On Mon, May 22, 2017 at 4:44 PM, Rishi Sharma <[hidden email]>
>> wrote:
>> >
>> >
>> > On Mon, May 22, 2017 at 1:11 PM, Igor Korot <[hidden email]> wrote:
>> >>
>> >> Hi,
>> >>
>> >> On Mon, May 22, 2017 at 4:03 PM, Rishi Sharma <[hidden email]>
>> >> wrote:
>> >> > In order to test it uses the correct image, I have img.png and
>> >> > [hidden email]
>> >> > (both are actually different images so I can tell which one is
>> >> > loaded).
>> >>
>> >> Are they both accessible?
>> >> Just for the test - can you try to load both of them and check that
>> >> the bitmap IsOk()
>> >> returns true?
>> >
>> >
>> > Done, both return True.  Are you able to get the 2x image loaded with
>> > the
>> > script below (using substitute images)?
>>
>> I don't have Mac with Retina.
>> Now you can successfully render the "@2" bitmap into the screen, right?
>> Maybe wxPython does not compile this code?
>
>
> Yeah, but its rendered scaled up for the 2.0 factor.  I'm not sure how
> wxPython would not compile the code since it seems to be in the wxwidgets
> source included with it.  I did originally download the binary though, so
> perhaps something in the binary had it off.
>
> I can't find a single success story about retina and wxPython via google so
> not sure whats up.

It is possible that wxPython release (code cut-off) was done prior to
this specific code
was put into wxWidgets.

Try building the wxWidgets Git HEAD along with wxPython Git HEAD and see if it
works.

Thank you.

>
>>
>>
>> Thank you.
>>
>> >
>> >>
>> >>
>> >> Thank you.
>> >>
>> >> >
>> >> > On Mon, May 22, 2017 at 1:02 PM, Rishi Sharma <[hidden email]>
>> >> > wrote:
>> >> >>
>> >> >> Hi!
>> >> >>
>> >> >> I have a Macbook Pro Retina Touchbar.  I made sure the screen is set
>> >> >> to
>> >> >> Default.
>> >> >>
>> >> >> This is what I have found so far.  I'm using wxPython 3.0.1.0
>> >> >> (although
>> >> >> I've tried to use the 4.0 version as well).  Below is a sample
>> >> >> script I
>> >> >> wrote (requires AppKit PyObjC to check for backingScaleFactor).  I
>> >> >> made
>> >> >> sure
>> >> >> to look at the backingScaleFactor and found it correctly it returns
>> >> >> 2.
>> >> >> I'm
>> >> >> looking at the bitmap code block and do see support:
>> >> >>
>> >> >>         if  ( type == wxBITMAP_TYPE_PNG )
>> >> >>         {
>> >> >>             if ( wxOSXGetMainScreenContentScaleFactor() > 1.9 )
>> >> >>             {
>> >> >>                 wxFileName fn(filename);
>> >> >>                 fn.MakeAbsolute();
>> >> >>                 fn.SetName(fn.GetName()+"@2x");
>> >> >>
>> >> >>                 if ( fn.Exists() )
>> >> >>                 {
>> >> >>                     fname = fn.GetFullPath();
>> >> >>                     scale = 2.0;
>> >> >>                 }
>> >> >>             }
>> >> >>         }
>> >> >>
>> >> >> I just have no idea why its not working.  Here is the sample:
>> >> >>
>> >> >> import AppKit as AK
>> >> >> import wx
>> >> >>
>> >> >> class MyFrame(wx.Frame):
>> >> >>   def __init__(self, parent):
>> >> >>     wx.Frame.__init__(self, parent, -1, "Retina Demo")
>> >> >>     print AK.NSScreen.screens()[0].backingScaleFactor()
>> >> >>     path = "img.png"
>> >> >>     bmp = wx.EmptyBitmap( 1, 1 )
>> >> >>     bmp.LoadFile(path, wx.BITMAP_TYPE_PNG)
>> >> >>     bmp = wx.StaticBitmap(self, -1, bmp)
>> >> >>     sizer = wx.BoxSizer(wx.VERTICAL)
>> >> >>     sizer.Add(bmp, 1, wx.ALL|wx.EXPAND, 5)
>> >> >>     self.SetSizer(sizer)
>> >> >>     sizer.Fit(self)
>> >> >>     self.Layout()
>> >> >>
>> >> >> app = wx.App()
>> >> >> frame = MyFrame(None)
>> >> >> app.SetTopWindow(frame)
>> >> >> frame.Show()
>> >> >> app.MainLoop()
>> >> >>
>> >> >> On Mon, May 22, 2017 at 12:20 PM, Igor Korot <[hidden email]>
>> >> >> wrote:
>> >> >>>
>> >> >>> Hi,
>> >> >>>
>> >> >>> On Mon, May 22, 2017 at 3:13 PM, Rishi Sharma
>> >> >>> <[hidden email]>
>> >> >>> wrote:
>> >> >>> > Hi everyone,
>> >> >>> >
>> >> >>> > I understand wxPython has support for retina text, but no matter
>> >> >>> > what I
>> >> >>> > do I
>> >> >>> > cannot get retina support working for images.
>> >> >>> >
>> >> >>> > Does anyone have an idea on how to get it to work if possible? Do
>> >> >>> > I
>> >> >>> > need to
>> >> >>> > patch wxWidgets and rebuild wxPython?  Whats the least version
>> >> >>> > that
>> >> >>> > supports
>> >> >>> > retina?
>> >> >>> >
>> >> >>> > If anyone has a sample demo script that works I'd appreciate an
>> >> >>> > example.
>> >> >>>
>> >> >>> What is your {wx}python versions?
>> >> >>> What OSX version?
>> >> >>> Are you sure you have a Retina display?
>> >> >>>
>> >> >>> Thank you.
>> >> >>>
>> >> >>> >
>> >> >>> > Thanks,
>> >> >>> >
>> >> >>> > -R
>> >> >>> >
>> >> >>> > --
>> >> >>> > You received this message because you are subscribed to the
>> >> >>> > Google
>> >> >>> > Groups
>> >> >>> > "wxPython-users" group.
>> >> >>> > To unsubscribe from this group and stop receiving emails from it,
>> >> >>> > send
>> >> >>> > an
>> >> >>> > email to [hidden email].
>> >> >>> > For more options, visit https://groups.google.com/d/optout.
>> >> >>>
>> >> >>> --
>> >> >>> You received this message because you are subscribed to the Google
>> >> >>> Groups
>> >> >>> "wxPython-users" group.
>> >> >>> To unsubscribe from this group and stop receiving emails from it,
>> >> >>> send
>> >> >>> an
>> >> >>> email to [hidden email].
>> >> >>> For more options, visit https://groups.google.com/d/optout.
>> >> >>
>> >> >>
>> >> >
>> >> > --
>> >> > You received this message because you are subscribed to the Google
>> >> > Groups
>> >> > "wxPython-users" group.
>> >> > To unsubscribe from this group and stop receiving emails from it,
>> >> > send
>> >> > an
>> >> > email to [hidden email].
>> >> > For more options, visit https://groups.google.com/d/optout.
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "wxPython-users" group.
>> >> To unsubscribe from this group and stop receiving emails from it, send
>> >> an
>> >> email to [hidden email].
>> >> For more options, visit https://groups.google.com/d/optout.
>> >
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "wxPython-users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to [hidden email].
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "wxPython-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [hidden email].
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "wxPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Retina images in wxPython

dontblink
I checked the source for that version: https://cytranet.dl.sourceforge.net/project/wxpython/wxPython/3.0.1.0/wxPython-src-3.0.1.0.tar.bz2 and the code block is in there.

Additionally I tried the same script with 4.0a and it doesn't work either (which undoubtedly would have the changes).

I'm trying to build that version but keep getting errors in wxWidgets.  I guess I'm missing the "ar" utility need to build it.  So more googling.



On Mon, May 22, 2017 at 2:34 PM, Igor Korot <[hidden email]> wrote:
Hi,

On Mon, May 22, 2017 at 5:08 PM, Rishi Sharma <[hidden email]> wrote:
>
>
> On Mon, May 22, 2017 at 1:56 PM, Igor Korot <[hidden email]> wrote:
>>
>> Hi,
>>
>> On Mon, May 22, 2017 at 4:44 PM, Rishi Sharma <[hidden email]>
>> wrote:
>> >
>> >
>> > On Mon, May 22, 2017 at 1:11 PM, Igor Korot <[hidden email]> wrote:
>> >>
>> >> Hi,
>> >>
>> >> On Mon, May 22, 2017 at 4:03 PM, Rishi Sharma <[hidden email]>
>> >> wrote:
>> >> > In order to test it uses the correct image, I have img.png and
>> >> > [hidden email]
>> >> > (both are actually different images so I can tell which one is
>> >> > loaded).
>> >>
>> >> Are they both accessible?
>> >> Just for the test - can you try to load both of them and check that
>> >> the bitmap IsOk()
>> >> returns true?
>> >
>> >
>> > Done, both return True.  Are you able to get the 2x image loaded with
>> > the
>> > script below (using substitute images)?
>>
>> I don't have Mac with Retina.
>> Now you can successfully render the "@2" bitmap into the screen, right?
>> Maybe wxPython does not compile this code?
>
>
> Yeah, but its rendered scaled up for the 2.0 factor.  I'm not sure how
> wxPython would not compile the code since it seems to be in the wxwidgets
> source included with it.  I did originally download the binary though, so
> perhaps something in the binary had it off.
>
> I can't find a single success story about retina and wxPython via google so
> not sure whats up.

It is possible that wxPython release (code cut-off) was done prior to
this specific code
was put into wxWidgets.

Try building the wxWidgets Git HEAD along with wxPython Git HEAD and see if it
works.

Thank you.

>
>>
>>
>> Thank you.
>>
>> >
>> >>
>> >>
>> >> Thank you.
>> >>
>> >> >
>> >> > On Mon, May 22, 2017 at 1:02 PM, Rishi Sharma <[hidden email]>
>> >> > wrote:
>> >> >>
>> >> >> Hi!
>> >> >>
>> >> >> I have a Macbook Pro Retina Touchbar.  I made sure the screen is set
>> >> >> to
>> >> >> Default.
>> >> >>
>> >> >> This is what I have found so far.  I'm using wxPython 3.0.1.0
>> >> >> (although
>> >> >> I've tried to use the 4.0 version as well).  Below is a sample
>> >> >> script I
>> >> >> wrote (requires AppKit PyObjC to check for backingScaleFactor).  I
>> >> >> made
>> >> >> sure
>> >> >> to look at the backingScaleFactor and found it correctly it returns
>> >> >> 2.
>> >> >> I'm
>> >> >> looking at the bitmap code block and do see support:
>> >> >>
>> >> >>         if  ( type == wxBITMAP_TYPE_PNG )
>> >> >>         {
>> >> >>             if ( wxOSXGetMainScreenContentScaleFactor() > 1.9 )
>> >> >>             {
>> >> >>                 wxFileName fn(filename);
>> >> >>                 fn.MakeAbsolute();
>> >> >>                 fn.SetName(fn.GetName()+"@2x");
>> >> >>
>> >> >>                 if ( fn.Exists() )
>> >> >>                 {
>> >> >>                     fname = fn.GetFullPath();
>> >> >>                     scale = 2.0;
>> >> >>                 }
>> >> >>             }
>> >> >>         }
>> >> >>
>> >> >> I just have no idea why its not working.  Here is the sample:
>> >> >>
>> >> >> import AppKit as AK
>> >> >> import wx
>> >> >>
>> >> >> class MyFrame(wx.Frame):
>> >> >>   def __init__(self, parent):
>> >> >>     wx.Frame.__init__(self, parent, -1, "Retina Demo")
>> >> >>     print AK.NSScreen.screens()[0].backingScaleFactor()
>> >> >>     path = "img.png"
>> >> >>     bmp = wx.EmptyBitmap( 1, 1 )
>> >> >>     bmp.LoadFile(path, wx.BITMAP_TYPE_PNG)
>> >> >>     bmp = wx.StaticBitmap(self, -1, bmp)
>> >> >>     sizer = wx.BoxSizer(wx.VERTICAL)
>> >> >>     sizer.Add(bmp, 1, wx.ALL|wx.EXPAND, 5)
>> >> >>     self.SetSizer(sizer)
>> >> >>     sizer.Fit(self)
>> >> >>     self.Layout()
>> >> >>
>> >> >> app = wx.App()
>> >> >> frame = MyFrame(None)
>> >> >> app.SetTopWindow(frame)
>> >> >> frame.Show()
>> >> >> app.MainLoop()
>> >> >>
>> >> >> On Mon, May 22, 2017 at 12:20 PM, Igor Korot <[hidden email]>
>> >> >> wrote:
>> >> >>>
>> >> >>> Hi,
>> >> >>>
>> >> >>> On Mon, May 22, 2017 at 3:13 PM, Rishi Sharma
>> >> >>> <[hidden email]>
>> >> >>> wrote:
>> >> >>> > Hi everyone,
>> >> >>> >
>> >> >>> > I understand wxPython has support for retina text, but no matter
>> >> >>> > what I
>> >> >>> > do I
>> >> >>> > cannot get retina support working for images.
>> >> >>> >
>> >> >>> > Does anyone have an idea on how to get it to work if possible? Do
>> >> >>> > I
>> >> >>> > need to
>> >> >>> > patch wxWidgets and rebuild wxPython?  Whats the least version
>> >> >>> > that
>> >> >>> > supports
>> >> >>> > retina?
>> >> >>> >
>> >> >>> > If anyone has a sample demo script that works I'd appreciate an
>> >> >>> > example.
>> >> >>>
>> >> >>> What is your {wx}python versions?
>> >> >>> What OSX version?
>> >> >>> Are you sure you have a Retina display?
>> >> >>>
>> >> >>> Thank you.
>> >> >>>
>> >> >>> >
>> >> >>> > Thanks,
>> >> >>> >
>> >> >>> > -R
>> >> >>> >
>> >> >>> > --
>> >> >>> > You received this message because you are subscribed to the
>> >> >>> > Google
>> >> >>> > Groups
>> >> >>> > "wxPython-users" group.
>> >> >>> > To unsubscribe from this group and stop receiving emails from it,
>> >> >>> > send
>> >> >>> > an
>> >> >>> > email to [hidden email].
>> >> >>> > For more options, visit https://groups.google.com/d/optout.
>> >> >>>
>> >> >>> --
>> >> >>> You received this message because you are subscribed to the Google
>> >> >>> Groups
>> >> >>> "wxPython-users" group.
>> >> >>> To unsubscribe from this group and stop receiving emails from it,
>> >> >>> send
>> >> >>> an
>> >> >>> email to [hidden email].
>> >> >>> For more options, visit https://groups.google.com/d/optout.
>> >> >>
>> >> >>
>> >> >
>> >> > --
>> >> > You received this message because you are subscribed to the Google
>> >> > Groups
>> >> > "wxPython-users" group.
>> >> > To unsubscribe from this group and stop receiving emails from it,
>> >> > send
>> >> > an
>> >> > email to [hidden email].
>> >> > For more options, visit https://groups.google.com/d/optout.
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "wxPython-users" group.
>> >> To unsubscribe from this group and stop receiving emails from it, send
>> >> an
>> >> email to [hidden email].
>> >> For more options, visit https://groups.google.com/d/optout.
>> >
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "wxPython-users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to [hidden email].
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "wxPython-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [hidden email].
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "wxPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...