Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: rrc1962 on May 24, 2016, 12:39:31 PM
-
Is there a way to set a static image so it won't stretch or resize with the screen? A way to lock the aspect ratio would work also. Anything to prevent the image from distorting. I was kind of hoping for a "resized" event attached to the tab panel object, but don't see anything like that.
Thanks
-
I'm guessing there is not a way to lock images. This is driving me nuts. I'm trying to make a nice looking screen with images and image buttons, but it's impossible when the images distort when the screen size changes.
-
There is a way but just not had time to go indepth with a vidieo yet, its done by using a panel and a wxstaticbitmap command, hopefully I will sort weekend.
DazTheGas
-
Another quick way is to make your screen editor screen the same size as the normal screen, this stops the sizers from sizing when exiting the editor.
DazTheGas
-
Static screen size doesn't really work because you never know what size screen a user will have. The fact that it resizes is actually a nice feature...One I always wished M3 had...It just doesn't work when applied to images and image buttons.
-
Not time for a video but try this..
from the screen editor
1. Add a lua panel and set the size the same as the image you want + 10 on both height and width
2. Add into the script part
local inst = mc.mcGetInstance()
panel = mcLuaPanelParent -- get the panels parent id
local window = panel:GetParent() -- get the panels id
local BGround = panel:GetBackgroundColour() -- get the screen background colour
window:SetBackgroundColour(BGround) -- set to background of top window
window:SetWindowStyleFlag(wx.wxBORDER_NONE) -- remove border
window:ClearBackground() -- clear background
window:Refresh() -- refresh to apply changes
local my_image = "C:\\DTG_Mach4Hobby\\Profiles\\ESS_Motion_V2\\Screen\\Buttons\\24v_dwn.png" -- bitmap to load
wx.wxStaticBitmap( window, wx.wxID_ANY, wx.wxBitmap( my_image , wx.wxBITMAP_TYPE_ANY ), wx.wxDefaultPosition, wx.wxDefaultSize, 0 ) -- create the bitmap container
window:Layout() -- redraw the new panel
This will create a bitmap that will not resize with the screen, the panel itself will but not the image.
DazTheGas
-
You're my hero! That works great.