3
$\begingroup$

I have a Panel of size {850, 400} as myPanel with a Pane of size {450, 400} and four images assigned to forwardPicture, backwardPicture, picture1 and picture2.

forwardPicture=

enter image description here

backwardPicture=

enter image description here

picture1=

enter image description here

picture2=

enter image description here

Both picture1 and picture2 are of size {400, 400},

myPanel = Panel[Row[{picture1, picture2}], ImageSize -> {850, 400}];

Row[{
  MouseAppearance[EventHandler[
    Framed[backwardPicture, 
     FrameStyle -> None], {"MouseClicked" :> ""}], "LinkHand"],
  Pane[myPanel, ImageSize -> {450, 400}, Scrollbars -> None], 
  MouseAppearance[EventHandler[
    Framed[forwardPicture, 
     FrameStyle -> None], {"MouseClicked" :> ""}], "LinkHand"]
  }]

After evaluation, I get this:

enter image description here

I want to move the images from right to left within the Pane whenever forwardPicture is pressed, and move them from left to right whenever backwardPicture is pressed. I don't want any scrollbars in the Pane. I don't want to move the images at one click: I want to move them a little bit for every click, until the full image is displayed. Can anybody help me?

$\endgroup$
2
  • $\begingroup$ István Zachar,we have to solve this problem very easily,If we have to fix the dimensions to the panel. why because,at the starting time Panel displayed with some certain dimensions(min:0,max:50),and then next dimensions increased like (min:10,max=60) whenever forwardPicture is pressed...I think like that ,so I mentioned "dimension". $\endgroup$
    – subbu
    Commented Nov 7, 2012 at 20:32
  • $\begingroup$ Ok, in the meantime I've figured it out :) $\endgroup$ Commented Nov 7, 2012 at 20:46

2 Answers 2

3
$\begingroup$

You can still use the ScrollPosition option in Pane, even though there are no scroll bars. Set this to a Dynamic value and make the "MouseClicked" action increase or decrease that value.

e.g.

DynamicModule[{s},
  Row[{
  MouseAppearance[EventHandler[Framed[backwardPicture, FrameStyle -> None],
    {"MouseClicked" :> (s -= 10)}], "LinkHand"], 
  Pane[myPanel, ImageSize -> {450, 400}, Scrollbars -> None, ScrollPosition -> Dynamic[{s, 0}]], 
  MouseAppearance[EventHandler[Framed[forwardPicture, FrameStyle -> None],
    {"MouseClicked" :> (s += 10)}], "LinkHand"]}]]
$\endgroup$
5
  • $\begingroup$ Simon Woods, Thanks for your reply...but moving Appearancewas bad..so How can I change that? $\endgroup$
    – subbu
    Commented Nov 7, 2012 at 20:52
  • $\begingroup$ @subbu, I'm not sure what you mean. Can you explain in more detail? $\endgroup$ Commented Nov 7, 2012 at 21:20
  • $\begingroup$ ImageSizeAction -> "Scrollable" might be an alternative -- in which case the forward and back arrows are probably redundant. $\endgroup$ Commented Nov 7, 2012 at 21:23
  • $\begingroup$ @Simon Woods,we have to see this type of application,whenever we have to open new tab in google chrome, in that moving Appearance was so good,whenever we have to press on forwardButton and Backwardbutton...can we provide Appearance like that? $\endgroup$
    – subbu
    Commented Nov 8, 2012 at 20:10
  • $\begingroup$ @subbu, I don't use google chrome. Can you describe what makes the appearance good? $\endgroup$ Commented Nov 8, 2012 at 21:09
3
$\begingroup$

I've used ImageAssemble to replace Row in myPanel, as Row is subject to linebreaks. The left/right step buttons use a +/-20 unit stepsize, this can be customized for the user's taste.

DynamicModule[{myPanel, max, d = 0},
 myPanel = 
  ImageAssemble@{ImageResize[picture1, {Automatic, 400}], 
    ImageResize[picture2, {Automatic, 400}]};
 max = First@ImageDimensions@myPanel;
 Panel@Row[{
    MouseAppearance[EventHandler[Framed[backwardPicture, 
       FrameStyle -> None], {"MouseClicked" :> (d = Min[d + 20, max - 450])}], 
     "LinkHand"],
    Pane[Show[myPanel, ImageSize -> {Automatic, 400}], 
     Scrollbars -> False, ImageSize -> {450, 400}, 
     ScrollPosition -> Dynamic@{d, 0}],
    MouseAppearance[EventHandler[
      Framed[forwardPicture, FrameStyle -> None], {"MouseClicked" :> (d = Max[0, d - 20])}],
      "LinkHand"]
    }]
 ]

Mathematica graphics

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.